Skip to content

Instantly share code, notes, and snippets.

@diceroll123
Last active April 6, 2022 00:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diceroll123/3c81b8073d911c889aa20341e3e18944 to your computer and use it in GitHub Desktop.
Save diceroll123/3c81b8073d911c889aa20341e3e18944 to your computer and use it in GitHub Desktop.
# 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