Last active
May 24, 2017 15:16
-
-
Save AlexVvx/8894811db96db62d373866b8db78bb12 to your computer and use it in GitHub Desktop.
open-day-solutions
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 getChange = (cost, sum) => { | |
let rem = Math.round((sum - cost) * 100); | |
return [100, 50, 20, 10, 5, 1].map(v => { | |
let n = ~~(rem / v); | |
rem -= n * v; | |
return n; | |
}).reverse(); | |
} | |
var zoom = (n, f=v=>Math.min(v,n-v-1)) => | |
Array.from({ length: n }).map((_, x) => | |
Array.from({ length: n }).map((_, y) => | |
Math.min(f(x), f(y)) % 2 ? '□' : '■' | |
).join('') | |
).join('\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment