Created
March 11, 2021 21:45
-
-
Save rene-d/b5a390684523f4e5034550d9e47de86a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| def chiffres(i): | |
| return i // 100, (i // 10) % 10, i % 10 | |
| def bad(a, b, place, desordre, absent): | |
| aa = a | |
| a = chiffres(a) | |
| b = chiffres(b) | |
| if a[0] == b[0]: | |
| place -= 1 | |
| if a[1] == b[1]: | |
| place -= 1 | |
| if a[2] == b[2]: | |
| place -= 1 | |
| if place != 0: | |
| return True | |
| if a[0] == b[1] or a[0] == b[2]: | |
| desordre -= 1 | |
| if a[1] == b[0] or a[1] == b[2]: | |
| desordre -= 1 | |
| if a[2] == b[0] or a[2] == b[1]: | |
| desordre -= 1 | |
| if desordre != 0: | |
| return True | |
| return False | |
| for i in range(111, 1000): | |
| if bad(i, 795, 0, 0, 3): | |
| continue | |
| if bad(i, 147, 0, 1, 0): | |
| continue | |
| if bad(i, 368, 1, 0, 0): | |
| continue | |
| if bad(i, 218, 0, 2, 0): | |
| continue | |
| if bad(i, 841, 1, 0, 0): | |
| continue | |
| if bad(i, 639, 0, 1, 0): | |
| continue | |
| print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment