Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
// Solve the "Coin Change" problem using a bottom-up dynamic programming
// approach. The time complexity is O(n * coins.length) since we have a nested
// loop. The storage complexity is the same, as we store a matrix.
//
// * `coins` is an array of the coin values, eg. [ 1, 2, 3 ]. We assume it
// to be non-empty.
// * `n` is the amount, eg. 4 cents.
//
@jeanlauliac
jeanlauliac / gist:7420473
Last active December 28, 2015 01:29
Extracted music genres from wikipedia, using the scrapper of the https://github.com/jeanlauliac/acenturyofmusic project.
{
"genres": {
"rock music": {
"title": "Rock music",
"url": "//en.wikipedia.org/wiki/Rock music",
"color": "crimson",
"stylistic_origins": [
"rock and roll",
"electric blues",
"jazz",
@jeanlauliac
jeanlauliac / example.csv
Last active December 27, 2015 08:58
Generates a CSV file describing, for each hour of each day of the week: "commit count / added lines / removed lines". An example of generated CSV is provided (generated by running the script on the 'git' git repository).
day lines
Tue 277/7004/2481;201/8576/3561;139/2653/1111;70/1752/664;43/1138/521;38/1587/534;32/1694/1032;82/3202/2554;77/3375/2663;225/15032/7769;219/4212/1857;284/5581/2007;301/7260/3817;270/5442/1764;323/15875/10476;316/9016/4161;312/8601/4115;176/2891/1278;218/9919/4118;177/6341/3024;176/5342/2042;342/12787/5304;348/13520/7663;360/13522/4729
Sat 200/5975/2634;184/4829/1570;174/7750/3008;97/3315/873;66/2982/664;42/3222/263;48/1539/668;51/3815/2047;35/2309/1611;82/1914/823;121/18503/13880;210/9587/3055;200/3238/1415;187/6255/2249;190/6619/2276;221/7146/2322;233/6229/4527;252/14667/6269;247/7457/1909;178/4527/2363;212/10811/7969;210/5942/3003;257/8527/3574;349/10693/3749
Thu 293/15092/10292;170/5804/1217;157/4758/1132;70/2226/969;35/955/341;35/1551/937;94/2733/1130;76/1326/330;92/6162/1266;165/6165/3808;290/8094/3213;250/10581/6861;294/5179/2342;296/8492/2996;322/7637/4346;325/7630/3695;283/10570/5174;233/12549/6286;205/8378/3970;256/6950/4600;225/4685/1888;245/8928/4822;320/8338/3088;334/9416/3282
Sun 229/80
@jeanlauliac
jeanlauliac / week-volumes.sh
Last active December 27, 2015 07:49
Compute git commit volumes for each hour of the week.
#!/bin/bash
git log --format=format:"%aD" | gawk '
match($0, /^([[:alnum:]]{3}), [[:digit:]]+ [[:alpha:]]{3} \
[[:digit:]]+ ([[:digit:]]+):[[:digit:]]+:[[:digit:]]+/, mt) {
days[mt[1]]["count"]++;
days[mt[1]]["hours"][+mt[2]]++;
total["count"]++;
total["hours"][+mt[2]]++;

Keybase proof

I hereby claim:

  • I am jeanlauliac on github.
  • I am jeanlauliac (https://keybase.io/jeanlauliac) on keybase.
  • I have a public key whose fingerprint is 78FB 9176 EF4C 2B14 FD86 7F56 ECEE A5F1 DDC2 93BF

To claim this, I am signing this object:

@jeanlauliac
jeanlauliac / balanced-delimiters.js
Created June 17, 2014 19:23
Solve the 'balanced delimiters' problem
#!/usr/bin/env node
'use strict';
var Delimiters = {
'[': ']'
, '(': ')'
, '{': '}'
}
// Javascript doesn't contain Sets, so we just use a map with booleans.