Created
January 27, 2020 19:50
-
-
Save franckc/cb78cc9220e5c1c47d3790b6658c1124 to your computer and use it in GitHub Desktop.
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
const seedrandom = require('seedrandom') | |
const fs = require('fs') | |
const numWinners = 30 | |
// Read hashes from a file. They are expected to be in block descending order (most recent first). | |
const hashes = fs.readFileSync('hashes.txt').toString().trim().split('\n') | |
// Seed a random generator with the most recent hash. | |
const randomGenerator = seedrandom(hashes[0]) | |
// Draw the winners, making sure to exclude duplicates. | |
const seen = {} | |
let index | |
console.log(`Out of ${hashes.length} participants, the ${numWinners} lucky winners are:`) | |
for (let i=1; i <= numWinners; i++) { | |
do { | |
index = Math.floor(randomGenerator() * hashes.length) | |
} while (seen[index]) | |
console.log(`#${i}:\t${hashes[index]}`) | |
seen[index] = true | |
} |
rusmani03
commented
Mar 12, 2020
via email
Gx dapet even februari ama maret?
Pada tanggal Kam, 12 Mar 2020 01:04, Paul lumere <notifications@github.com>
menulis:
… ***@***.**** commented on this gist.
------------------------------
Jangan maruk, minim 200 ogn sudah seneng 😯
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/cb78cc9220e5c1c47d3790b6658c1124#gistcomment-3208453>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK2PNX6QHZ7OPG5LQFKABN3RG7HEHANCNFSM4KOT5DDQ>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment