Skip to content

Instantly share code, notes, and snippets.

@licensed
Last active February 6, 2022 19:27
Show Gist options
  • Save licensed/0e6fa4726e10597407bff3effcb64b86 to your computer and use it in GitHub Desktop.
Save licensed/0e6fa4726e10597407bff3effcb64b86 to your computer and use it in GitHub Desktop.
Loteria / Mega Sena
#Simple Python Script for generate all possible combinations without repetitions
from itertools import combinations
# I want all possible combinations without repetition who haves numbers from 1 to 60
NUMBERS = 60
# Each possible combination haves 6 numbers
QUANTITY = 6
# Lines quantity by each file
LINES = 6000000
# Simple counter to control file lines limit
x = 1
for count, comb in enumerate(combinations(range(1, NUMBERS + 1), QUANTITY)):
if count > LINES:
x += 1
LINES *= 2
with open(f'combination{x}.txt', 'a') as f:
f.write(str(comb).replace('(', '').replace(')', '') + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment