Last active
April 6, 2022 00:56
-
-
Save diceroll123/3c81b8073d911c889aa20341e3e18944 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
# Credits to the original "lottery calculator" located here: | |
# https://www.andrew.cmu.edu/user/kmliu/neopets/details.html | |
# This code is a Python implementation written by me of the | |
# associated Javascript code from the page above, | |
# with results sorted to be easier to input manually. | |
import itertools | |
import random | |
from typing import List | |
def generate_lotto_numbers() -> List[List[int]]: | |
begin = list(range(1, 31)) | |
random.shuffle(begin) | |
def cut_leaf(arr: List[int]) -> List[int]: | |
return list( | |
itertools.chain.from_iterable(itertools.zip_longest(arr[:15], arr[15:])) | |
) | |
arr2 = cut_leaf(cut_leaf(begin)) | |
arr3 = cut_leaf(cut_leaf(arr2)) | |
arr4 = cut_leaf(cut_leaf(arr3)) | |
marr = begin + arr2 + arr3 + arr4 | |
result = [sorted([marr[(6 * i) + x] for x in range(6)]) for i in range(20)] | |
return sorted(result) | |
print(generate_lotto_numbers()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment