From 24727e27909310df30771798f75796f8cd2edd79 Mon Sep 17 00:00:00 2001 From: Skladnayazebra Date: Fri, 7 Aug 2026 22:18:43 +0200 Subject: not a place for notes.js --- notes.js | 57 --------------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 notes.js (limited to 'notes.js') diff --git a/notes.js b/notes.js deleted file mode 100644 index b80188c..0000000 --- a/notes.js +++ /dev/null @@ -1,57 +0,0 @@ -import { createInterface } from 'node:readline/promises'; - -const noteList = [ - ["do", "tidi"], - ["dodi", "rebe"], - ["re"], - ["redi", "mibe"], - ["mi", "fabe"], - ["fa", "midi"], - ["fadi", "sobe"], - ["so"], - ["sodi", "labe"], - ["la"], - ["ladi", "tibe"], - ["ti", "dobe"], -]; - -const MAX_INTERVAL = 4; - -const randomIndex = (array) => Math.floor(Math.random() * array.length); -const randomElement = (array) => array[randomIndex(array)]; - -const readline = createInterface({ - input: process.stdin, - output: process.stdout, -}); - -const makeTest = async () => { - const startingNoteIndex = randomIndex(noteList); - // random number between -$MAX_INTERVAL --- +$MAX_INTERVAL - const getInterval = () => Math.round((Math.random() * MAX_INTERVAL * 2) - MAX_INTERVAL); - const interval = getInterval() - const displayInterval = interval > 0 ? `+${interval}`: interval; - const displayStartingNote = randomElement(noteList[startingNoteIndex]) - // 11 + 4 should yield 3 - const targetIndex = (startingNoteIndex + interval) % noteList.length - const acceptedAnswers = noteList.at(targetIndex); - - performance.mark('start') - const response = await readline.question(`${displayStartingNote} ${displayInterval} `) - try { - if (acceptedAnswers.includes(response)) { - performance.mark('end') - const { duration } = performance.measure('time', 'start', 'end') - console.log('correct!', `Took ${Math.round(duration)/1000}s`); - } else { - console.log('wrong! should be:', acceptedAnswers.join(', or ')) - } - } catch (e) { - console.log('error!'); - console.log({ startingNoteIndex, interval, targetIndex }) - } -} - -while (true) { - await makeTest() -} -- cgit v1.3.1