Created
April 20, 2020 19:27
-
-
Save hugabor/52c3c577653b8e4fe4605eab20d0e873 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
| # create all combinations | |
| p_0 = [] | |
| for a in range(10): | |
| for b in range(10): | |
| for c in range(10): | |
| p_0.append([a, b, c]) | |
| # hint 1 | |
| # 682, 1 is correct and well placed | |
| p_1 = [] | |
| for p in p_0: | |
| if p[0] == 6 or p[1] == 8 or p[2] == 2: | |
| p_1.append(p) | |
| # hint 2 | |
| # 614, one is correct but wrong position | |
| p_2 = [] | |
| for p in p_1: | |
| if p[1] == 6 or p[2] == 6: | |
| p_2.append(p) | |
| continue | |
| if p[0] == 1 or p[2] == 1: | |
| p_2.append(p) | |
| continue | |
| if p[0] == 4 or p[1] == 4: | |
| p_2.append(p) | |
| continue | |
| # hint 3 | |
| # 738, nothing is correct | |
| p_3 = [] | |
| # for p in p_2: | |
| # if 7 in p or 3 in p or 8 in p: | |
| # continue | |
| # p_3.append(p) | |
| for p in p_2: | |
| if p[0] != 7 and p[1] != 3 and p[2] != 8: | |
| p_3.append(p) | |
| # hint 4 | |
| # 206, two numbers correct but wrong position | |
| p_4 = [] | |
| for p in p_3: | |
| if p[0] != 2 and p[1] != 0: | |
| if 2 in p and 0 in p: | |
| p_4.append(p) | |
| continue | |
| if p[0] != 2 and p[2] != 6: | |
| if 2 in p and 6 in p: | |
| p_4.append(p) | |
| continue | |
| if p[1] != 0 and p[2] != 6: | |
| if 0 in p and 6 in p: | |
| p_4.append(p) | |
| continue | |
| # hint 5 | |
| # 780, one number correct but wrong position | |
| p_5 = [] | |
| for p in p_4: | |
| if p[1] == 7 or p[2] == 7: | |
| p_5.append(p) | |
| continue | |
| if p[0] == 8 or p[2] == 8: | |
| p_5.append(p) | |
| continue | |
| if p[0] == 0 or p[1] == 0: | |
| p_5.append(p) | |
| continue | |
| print([''.join([str(i) for i in p]) for p in p_5]) | |
| # output is: ['042', '062', '862'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment