4 kyu
Snake Cube Solver
21 of 57Paul Robertson
Loading description...
Recursion
Geometry
Puzzles
Algorithms
Game Solvers
Graph Theory
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Python translation. Please review and approve.
(I'll update the JS version, to mix both kinds of outputs in the random tests | done)
.
Second image in the description is broken.
I'm seeing it. Is it still broken for you?
It's a link to http://www.mathematische-basteleien.de/snake01.gif Does that work outside of the description?
I can not figure out the sentence:
"For the purposes of this kata, the complete solution occupies a cube with vertices:
(0,0,0) (2,0,0) (0,2,0) (0,0,2) (2,2,0) (2,0,2) (0,2,2) (2,2,2)
and starts with the first cube in the corner position (0,0,0)."
Anybody can explain it. The valid solution is any 27-length path sastified the binary array, begin with
[0, 0, 0]
and end with any other corners?you fill a cube of size 3x3x3 (indexed 0->2), beginning at (0,0,0). That's your only constraints.
Congrats you. You are the moderator now :D
what is the correct configuration for solution in JS? trying with return [[0,0,0],[1,0,0],[2,0,0], ... ] and getting "[] - Solution does not match configuration"
The test checks that your solution matches the given starting configuration (a list of
1
s and0
s) of the snake. For example, the three values you give, correspond to a configuration starting with[0,0,...]
.JavaScript translation
Shouldn't a valid solution return
Just _
and no solution returnNothing
?Yes, that's the Haskell way. I have updated the kata to reflect this
(0,0,0)
? Why couldn't it start at any valid coordinate?.. but a very nice kata anyway. :]
Yes, all those points could be addressed. I'll try to improve the validation function soon.
I have added random unsolvable snakes, and added a check for self-intersecting solutions.
I'm not sure about dropping the restriction that solutions start at (0,0,0) The problem is that it adds five new initial states (Starting position + initial direction). It makes the solving function much slower to execute in ghci.
I'll take your word for it. Leave it at
(0,0,0)
.Really random snakes are uninteresting, I found, even without the
(0,0,0)
restriction.Actually, two new states. Snakes can only start on dark-coloured positions in the cube.
Also, I'm going to do some more testing with random snakes. There may yet be interesting ones.
Yes, you are quite right.
I suppose there are 2^27 = 134217728 possible snakes. But snakes with two or more adjacent 0's will never have a solution (I think that would be at least half of them). I have read that there are only 11487 different snakes which have a solution - not very many!
I have owned a wooden 4x4x4 'king snake cube' for about 5 years. Despite many hours of effort, I have never been able to solve it. Of course, a computer program can find a solution in a few seconds.
I also own a 4x4x4 snake cube, and also couldn't solve it. A few years back i wrote a Haskell program to solve it, i could reuse my code today. :) Thanks for making this.