I found this puzzle in the internet. It looks quite easy to solve, but if you want to dig deeper into this you can find quite interesting fact.
Solution (without spoilers):
Let's name those rules with letters as follows:
A 206 twoNumbersAreCorrectButWrongPlaced
B 682 oneNumberIsCorrectAndWellPlaced
C 614 oneNumberIsCorrectButWrongPlaced
D 780 oneNumberIsCorrectButWrongPlaced
E 738 nothingIsCorrect
How many codes is still in game after applying rules?
Count valid codes in case we are applying only two rules:
How many codes is still in game after applying rules?
Count valid codes in case we are applying only two rules:
X | A | B | C | D | E |
A | 69 | 14 | 25 | 25 | 42 |
B | 14 | 192 | 40 | 40 | 72 |
C | 25 | 40 | 386 | 144 | 152 |
D | 25 | 40 | 144 | 386 | 78 |
E | 42 | 72 | 152 | 78 | 343 |
Now let's focus on AB and another rule:
ABA 14
ABB 14
ABC 1
ABD 7
ABE 10
So if the winner exists we can focus on rules ABC to find it.
If you want to figure out how to solve it in java you can find answer on github [WARNING: spoiler in tests]:
No comments:
Post a Comment