This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Point; | |
import java.awt.geom.Point2D; | |
import java.io.*; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class TravellingSalesman { | |
public static void main(String[] args) throws NumberFormatException, IOException { | |
BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class bst: | |
def __init__(self, k, v): | |
self.left = None | |
self.right = None | |
self.v = v | |
self.k = k | |
self.size = 1 | |
def __str__(self): | |
# for debugging only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package arraybackedqueue; | |
import java.util.LinkedList; | |
import java.util.Random; | |
public class Queue { | |
private int head; | |
private int tail; | |
private int data[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* For the original problem statement, check http://mourjo.me/klotski_problem.pdf *) | |
exception NotFound | |
type 'e rel = 'e -> 'e list | |
type 'e prop = 'e -> bool | |
type ('a, 'set) set_operations = { | |
empty : 'set; (* The empty set. *) | |
mem : 'a -> 'set -> bool; (* [mem x s = true] iff [x] is in [s]. *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Commentary ;; | |
;; ;; | |
;; The goal for writing this started with the idea to have tests run in ;; | |
;; parallel using the leiningen plugin eftest ;; | |
;; https://github.com/weavejester/eftest. ;; | |
;; ;; | |
;; With tests using with-redefs, it was not possible to run them in ;; | |
;; parallel if they were changing the root binding of the same ;; | |
;; vars. Here, we are binding the root of the var to one function that ;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns plank.core | |
(:import (java.util.regex Pattern))) | |
; Problem Statement: Write code to solve this problem | |
; Given a set of news articles find articles that match the search query from a user. | |
; Assume that the search query is a single word. | |
; | |
; Each article has this structure: Id,Headline,Content | |
; Articles cannot be updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2.2' | |
services: | |
es01: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1 | |
container_name: es01 | |
environment: | |
- node.name=es01 | |
- cluster.name=es-docker-cluster | |
- discovery.type=single-node | |
- bootstrap.memory_lock=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs, { readFileSync } from 'fs'; | |
import readline from 'readline'; | |
const YEAR = '2021'; | |
function infer(row) { | |
const ts = row.match(/startDate=".*?"/g)[0].match(/.?.?.?.?-.?.?-.?.? .?.?:.?.?:.?.? .?.?.?.?.?/)[0] | |
const dt = ts.substring(0, 10) | |
if (dt.startsWith(YEAR)) { | |
const unit = row.match(/unit=".*?"/)[0].match(/".?.?"/)[0].substring(1, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn prime? | |
[x] | |
(not-any? (fn [factor] (zero? (mod x factor))) | |
(range 2 (dec x)))) | |
(defn eager-primes | |
([n] (eager-primes n 2 [])) | |
([n curr xs] | |
(if (= n (count xs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as nodeWorker from 'worker_threads'; | |
function sleep(ms) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, ms); | |
}); | |
} | |
async function doSomething(name) { | |
console.log(`${Date.now()}: Worker ${name} working ...`); | |
await sleep(Math.floor(10000)); |
OlderNewer