Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rules = [
- ('682', 1, 0),
- ('614', 0, 1),
- ('206', 0, 2),
- ('738', 0, 0),
- ('380', 0, 1)
- ]
- def check(guess, correct):
- right_in_place = 0
- right_wrong_place = 0
- for i in range(3):
- if guess[i] in correct:
- if guess[i] == correct[i]:
- right_in_place += 1
- else:
- right_wrong_place += 1
- return right_in_place, right_wrong_place
- solutions = []
- for n in range(1000):
- trial = "{:03d}".format(n)
- valid = True
- for guess, right_in_place, right_wrong_place in rules:
- rp, rw = check(guess, trial)
- if rp != right_in_place or rw != right_wrong_place:
- valid = False
- break
- if valid:
- solutions.append(trial)
- print(solutions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement