Programming/Python
파이썬 1부터 45까지의 숫자로 만들 수 있는 모든 6개 숫자 조합
코큰강코
2024. 1. 16. 16:08
반응형
코드는 다음과 같습니다.
from itertools import combinations
def write_combinations_to_text(filepath='c:/test.txt'):
all_combinations = list(combinations(range(1, 46), 6))
with open(filepath, 'w') as textfile:
for combination in all_combinations:
sorted_combination = sorted(combination)
textfile.write(','.join(map(str, sorted_combination)) + '\n')
print(f"Combinations written to {filepath}")
write_combinations_to_text()
결과

45C6의 순열 결과, 8,145,060 개의 조합이 나옵니다.
1Line에 1,000원이면,
8,145,060,000원을 투자하여 매주 위 숫자 조합의 로또를 전부 구매하면 무조건 1등에 당첨됩니다.
다만, 1등 당첨금이 10,578,000,000원 이하라면 손해가 발생합니다.
728x90
반응형