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
(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
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
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
(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
(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
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
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
/*Question 1: Sum to 100 | |
Write a function that, given a string of digits, build an expression such that the digits will sum to 100 by inserting +, - anywhere between the digits. | |
For example, given the input 123456789, one such expression is 1 + 23 - 4 + 5 + 6 + 78 - 9 = 100 | |
Your function should return all possible combinations. | |
*/ | |
var results = {}; | |
function calc(n, s, part) { | |
if (n === 0 && s === '' && part[0] !== '-') return results[part.substring(1)] = null |
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 i = 0; | |
var bigest = (bytes) => { | |
console.log(i++, bytes); | |
try { | |
return new ArrayBuffer(bytes) | |
} catch (e) { | |
return bigest(bytes / 2) | |
} | |
} |