Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @Humanosaure,validated by @Timinator,@cedricdd and @Rafarafa.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @Humanosaure,validated by @Timinator,@cedricdd and @Rafarafa.
If you have any issues, feel free to ping them.
Hello,
I’m just wondering how people solved this puzzle. I used genetic algorithm to solve it. In my opinion brute force doesn’t work on this kind of problem. A very simple puzzle to build but to solve…
What language did you use?
I used Python 3, but the only relevant feature of python for this puzzle was the “itertools”. For the rest it is only list…
The genetic algorithme converge quickly : 19 generations for the last test with a gene size of 100 (with mutations, crossover and permutations)
I also used Python. My code is published, so you should be able to see it. I’d be glad to discuss my approach after you have a chance to digest it. I’d also love to take a look at your code, but it does not appear to be published. Would you be willing to publish it? If you’d prefer not to, you could send it to me in a private message.
Hello Timinator. My code now seems to be published. I understood you used a brute force with “escaping”. I thought about doing that but I was afraid to not have a converge within the time left, but I was wrong. So, I tried genetics which are well-known to perform this kind of problem. Such also as the Travelling Salesman, which I try currently.
The constraints says <=7, but looks like the test cases go up to 8 columns
Thank you for reporting the issue. I’ve fixed the second constraint.
ok, testcase 3 : The answer is suppossed to be 40422, but I’m finding a match with 44423
History => Bull,Cow/ 40422 / 44423
23414 => 1,2 / C B C 1,2 / C BC 1,2
11320 => 1,1 / BC 1,1 / CB 1,1
23430 => 1,2 / C B C 1,2 / CCB 1,2
03321=> 1,1 / C B 1,1 / C B 1,1
23421=> 2,1 / C BB 2,1 / BBC 2,1
the comparisons appear to line up. Where am i screwing up? it seems like since there is no 0 bull element, the cows can play leap frog and I get same result on all the histories. I’m not certain the JS solution is doing the white pegs properly. Nor my code either. But i’ve been over the comparisons multiple times and cannot find where i miscounted… my only conclusion is that there is more than 1 solution. But I haven’t run a full exhaustive search offline to make sure. ???
nevermind, i fixed it