Problem 44376. The sliding puzzle: 3D
Solution Stats
Problem Comments

8 Comments
there is a bug in the evaluation function, I believe "abs(a1 + b1 + c1  a0  b0  c0) == 1" should be changed to "abs(a1a0) + abs(b1b0) + abs(c1c0) == 1". In any way, this was a very cool problem, unless I am misremembering this would be the very first one that forced me to implement some version of A* in Cody :)
Alfonso, it is an honor and a pleasure to have read your comment. I'm glad you enjoyed the problem. Thank you for spotting the bug. I will update accordingly.
Alfonso, I've fixed the bug. As a result, I've actually located a tiny typo, one single character in my own solution that was, in fact, the difference between a correct and an incorrect solution based on your correction. Fixed that too, of course. Thanks again!
It takes 9 seconds to solve the four inputs on my laptop, but the system rejected my code with the error of long run time. What's the acceptable time for the four inputs?
This one kept my busy, and I think my solution is a bit of a tour de force. It is recipe based, rather than optimal, but there are just too many corner cases to program around. I should have made better use of invariant sets, I guess.
Difficult problem
Good problem. Tip: use the L1norm or manhattan distance using the 3 indexes as a cost function.
I am actually giving up :(
tried a lot......
Solution Comments

1 Comment
Cheater!

1 Comment
Can someone remove this cheating solution?

4 Comments
wow, I love everything about this solution, the equivalence with a 3x9 board, the BubbleSort strategy, even the 190size :)
Thank you.
I fail at BubbleSort. It always leaves a cube in the corner at the vertice of the big cube. Can someone help me? ;)
I solved it. Bubble sort is a handy way. Thanks.

1 Comment
Thank you, Alfonso!
This is a great lesson on how to code in MATLAB.

5 Comments
This problem was so difficult for me to solve, would you mind explaining what search algorithm did you implement? Thanks.
It is a bestfirst search using a heuristic based on the sum of manhattan distances to target for each of the 26 tiles; solution 1310071 is slightly commented in case that helps
@daniel and by the way congrats on finishing all cody5hard problems, that is quite an accomplishment! (I had it easier, having created a couple of problems in that same group, so mine does not count :)
I tried a similiar search but it did not end on time, and I don't know why.
PD: You're being too modest! I've been pulling all nighters all the week to finish them all, I'm sure it didn't take you all that time to solve them all.
PD2: I've made a problem (44390) in honour to all the suffering and latter satisfaction these 5th anniversay problems brought to me, you should check it out :)
I have tried something similar to this "bestfirst search" algorithm (if I understand the term correctly), but as I get closer to the final solution, I keep running into situations where all of the available moves move a tile out of its correct position, so my heuristic judges all of them equally, and the algorithm just starts making pseudorandom moves. Are you looking at all possibilities of some small number of moves, and picking one set of moves to move on from?
Problem Recent Solvers48
Suggested Problems

23156 Solvers

2056 Solvers

220 Solvers

680 Solvers

Spot the First Occurrence of 5
406 Solvers
More from this Author38
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!