Created
January 6, 2022 13:40
-
-
Save spyesx/be67da8ddf661fa852a377adc0ace970 to your computer and use it in GitHub Desktop.
mark6 lazy generator in javascript
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 options = { | |
n6 : { price: 10, columns: 6 }, | |
n7 : { price: 70, columns: 7 }, | |
n8 : { price: 280, columns: 8 } | |
} | |
const opt = 'n7' | |
const rows = 10 | |
const columns = options[opt].columns | |
const min = 1 | |
const max = 49 | |
const results = [] | |
const getRich = () => { | |
const numbers = [] | |
while (numbers.length < columns) { | |
const lucky = Math.floor( (Math.random() * (max - min + 1)) + min) | |
!numbers.includes(lucky) && numbers.push(lucky) | |
} | |
return numbers.sort((a, b) => a - b).join(', ') | |
} | |
for (let y = 1; y <= rows; y++) { | |
console.log(`Ticket ${y}: ${getRich()}`) | |
} | |
console.log(` | |
Tickets: ${rows} | |
Numbers per tickets: ${options[opt].columns} | |
Total price: ${options[opt].price * rows} | |
`) | |
/* | |
Ticket 1: 12, 13, 19, 25, 28, 37, 40 | |
Ticket 2: 6, 11, 16, 17, 20, 43, 48 | |
Ticket 3: 1, 8, 9, 37, 40, 47, 49 | |
Ticket 4: 7, 12, 17, 18, 39, 45, 48 | |
Ticket 5: 15, 34, 37, 40, 43, 48, 49 | |
Ticket 6: 11, 15, 19, 22, 28, 34, 45 | |
Ticket 7: 4, 6, 14, 17, 40, 42, 44 | |
Ticket 8: 5, 19, 24, 26, 36, 40, 45 | |
Ticket 9: 5, 10, 12, 14, 18, 21, 45 | |
Ticket 10: 8, 14, 20, 24, 28, 32, 47 | |
Tickets: 10 | |
Numbers per tickets: 7 | |
Total price: 700 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment