Created
June 26, 2019 14:16
-
-
Save Ginden/aba95899da702b6b9b67ddbddf1f7dee to your computer and use it in GitHub Desktop.
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
const _ = require('lodash'); | |
function bm() { | |
var u = 0, v = 0; | |
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1) | |
while(v === 0) v = Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
console.log( | |
_(_.range(1900, 2020)) | |
.map(x => [x, (25 + 3 * bm() + (x-1900)/100)]) | |
.sortBy(1) | |
.reverse() | |
.slice(0,20) | |
.map(0) | |
.filter(x => x < 2000) | |
.value() | |
.length | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment