Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- digits = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
- def one_in_place(a, b, c):
- return [
- [{a}, digits - {b}, digits - {c}],
- [digits - {a}, {b}, digits - {c}],
- [digits - {a}, digits - {b}, {c}]
- ]
- def one_wrong_place(a, b, c):
- remaining = digits - {a, b, c}
- return [
- [{b, c}, remaining, remaining],
- [remaining, {a, c}, remaining],
- [remaining, remaining, {a, b}]
- ]
- def two_wrong_place(a, b, c):
- remaining = digits - {a, b, c}
- return [
- [{b, c}, {a, c}, remaining],
- [{b, c}, remaining, {a, c}],
- [remaining, {a, c}, {a, b}]
- ]
- def all_wrong(a, b, c):
- remaining = digits - {a, b, c}
- return [ [remaining, remaining, remaining] ]
- rules = [
- one_in_place(6, 8, 2),
- one_wrong_place(6, 1, 4),
- two_wrong_place(2, 0, 6),
- all_wrong(7, 3, 8),
- one_wrong_place(7, 8, 0)
- ]
- for a in range(10):
- for b in range(10):
- for c in range(10):
- match = True
- for rule in rules:
- rule_match = False
- for set in rule:
- if a in set[0] and b in set[1] and c in set[2]:
- rule_match = True
- if not rule_match:
- match = False
- break
- if match:
- print(f"Matching code found: {a}{b}{c}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement