This file contains hidden or 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
var fs = require('fs'); | |
var AVLTree = require('avl'); | |
var tree = new AVLTree(); | |
var map = fs.readFileSync('map.txt', 'utf-8').split('\n').map(l => l.split(' ').map(c => Number(c))); | |
var [I, J] = map.shift(); | |
var result = { | |
path: 0, | |
drop: 0 | |
}; |
This file contains hidden or 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
var | |
fetch = require('node-fetch'), | |
md5 = require('md5'), | |
md5s = ["e4820b45d2277f3844eac66c903e84be", "23170acc097c24edb98fc5488ab033fe", "665e5bcb0c20062fe8abaaf4628bb154"], | |
match_md5 = frase => md5s.indexOf(md5(frase)) !== -1, | |
word2map = word => word.split('').reduce((acc, c) => {acc[c] = acc[c] || 0; acc[c]++; return acc}, {}), | |
match = rm => word => { | |
var char, i = 0, wm = {}; | |
while (i < word.length) { | |
char = word[i]; |
This file contains hidden or 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
(let [n_ (Integer/parseInt (read-line)) | |
i (fn [] (map #(Integer/parseInt %) (clojure.string/split (read-line) #" "))) | |
[x0 y0] (i)] | |
(loop [n n_ | |
min_x x0 | |
min_y y0] | |
(if (= n 1) | |
(println (* min_x min_y)) | |
(let [[x y] (i)] | |
(recur |
This file contains hidden or 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
(require '[clj-time.core :as t]) | |
(require '[clj-time.predicates :as pr]) | |
(require '[clj-time.coerce :as c]) | |
(defn add_hours_for_day_in_week [week weekday hours] | |
"Update day in a week by adding new business hours." | |
(assoc | |
week | |
(dec weekday) |
This file contains hidden or 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
VladimisMacBook:flat_json a$ mix hex.publish | |
Publishing flat_json 0.1.0 | |
App: flat_json | |
Name: flat_json | |
Files: | |
lib/flat_json.ex | |
mix.exs | |
README.md | |
Description: Decode string with flat JSON to Map | |
Version: 0.1.0 |
This file contains hidden or 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
test.cb('PUT /api/stocks/1 (update the price of a single stock)', t => { | |
const | |
app = webserver(createList(), port()); | |
request(app) | |
.post('/api/stocks') | |
.send({name: 'EUR', currentPrice: 1}) | |
.expect(200) | |
.then(res => res.body.id) | |
.then(id => request(app) |
This file contains hidden or 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
(def s (Integer/parseInt (read-line))) | |
(def stdin (read-line)) | |
(def nums (vec (map #(Integer/parseInt %) (clojure.string/split stdin #" ")))) | |
(defn insertOne [position collection size] | |
(let [v (nth collection position)] | |
(loop [a collection | |
p (dec position)] | |
(if (= p -1) |
This file contains hidden or 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
var | |
toAdd = true, | |
notToAdd = false, | |
events = [ | |
{start: 1, end: 5}, | |
{start: 2, end: 3}, | |
{start: 4, end: 6}, | |
{start: 7, end: 8}, | |
{start: 9, end: 10}, | |
{start: 10, end: 11}, |
This file contains hidden or 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 doubleBooked [events] | |
(let [sortedEvents (sort-by :start events) | |
toAdd true | |
notToAdd false] | |
(loop [head (first sortedEvents) | |
isAdd notToAdd | |
events (rest sortedEvents) | |
intersect []] | |
(let [neck (first events) | |
tail (rest events)] |
This file contains hidden or 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 a2s [a] | |
(reduce | |
(fn [s n] | |
(str s (str " " n))) | |
(str (first a)) | |
(rest a))) |