58 lines
1.1 KiB
Python
Executable File
58 lines
1.1 KiB
Python
Executable File
#! env python3
|
|
|
|
from random import randrange
|
|
|
|
def existing_combination(number, reds, combinations):
|
|
for red in reds:
|
|
if (red + number) in combinations:
|
|
return True
|
|
return False
|
|
|
|
def update_combinations(number, reds, combinations):
|
|
for red in reds:
|
|
combinations.append(red + number)
|
|
return combinations
|
|
|
|
debug = True
|
|
red_size = 6
|
|
blue_size = red_size
|
|
reds = []
|
|
blues = []
|
|
combinations = []
|
|
|
|
for i in range(red_size):
|
|
new_number = randrange(99)
|
|
|
|
while new_number in reds:
|
|
new_number = randrange(99)
|
|
|
|
reds.append(new_number)
|
|
|
|
if debug:
|
|
print(f'red #{i+1} found')
|
|
|
|
reds.sort()
|
|
if debug:
|
|
print(reds)
|
|
|
|
for i in range(blue_size):
|
|
new_number = randrange(99)
|
|
|
|
while new_number in reds or new_number in blues or existing_combination(new_number, reds, combinations):
|
|
new_number = randrange(99)
|
|
|
|
blues.append(new_number)
|
|
combinations = update_combinations(new_number, reds, combinations)
|
|
|
|
if debug:
|
|
print(f'blue #{i+1} found')
|
|
|
|
blues.sort()
|
|
combinations.sort()
|
|
|
|
if debug:
|
|
print(blues)
|
|
print(combinations)
|
|
|
|
# vim: set sw=2 ts=2 et:
|