Created
August 24, 2021 23:56
-
-
Save Merlin04/2b42e0fd6b7c6ee014638a2e04702213 to your computer and use it in GitHub Desktop.
Short script to assist with ranking a list of items
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 fs = require("fs"); | |
const items = [ | |
// List of items | |
]; | |
function prompt(input) { | |
const b = Buffer.alloc(1024); | |
console.log(input); | |
fs.readSync(fs.openSync("/dev/tty"), b); | |
return b.toString()[0]; | |
} | |
const getRandomItem = () => items[Math.floor(Math.random() * items.length)]; | |
const db = Object.fromEntries(items.map(item => [item, 0])); | |
const limit = 50; | |
for(i = 0; i < limit; i++) { | |
const i1 = getRandomItem(); | |
let i2 = undefined; | |
while(!i2) { | |
i2 = getRandomItem(); | |
if(i2 === i1) i2 = undefined; | |
} | |
const res = prompt(`${i1} vs ${i2}`); | |
db[res === "1" ? i1 : i2]++; | |
} | |
console.log(db); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment