Last active
August 26, 2016 20:20
-
-
Save bhalash/612f57ff222a920bf5e2a7f3b3e0e514 to your computer and use it in GitHub Desktop.
Doublers
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
var doublers = [ | |
n => n * 2, | |
n => n + n, | |
n => n << 1 | |
]; | |
var double = n => _.sample(doublers)(n), | |
verifyDoubling = (n, x) => n * 2 === x; | |
var a = []; | |
a = _.times(100, i => verifyDoubling(i, double(i))); | |
a = _.reduce(a, (last, n) => n && n === last, true); | |
console.log(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment