I was bored today at school and so I tried to amuse myself using my calculator and a "game" I've invented which isn't really a game but keeps the boringness away. Also some time has passed since the last real code-golf here, so I decided to create this one.
Imagine a simplified numpad like you know it from your phone (I'll leave the 0 out for this code-golf as it kinda destroys all the fun)
1 2 3
4 5 6
7 8 9
Now the rules of the game were always:
At the end every digit must have been visited exactly once
You can start at any digit you want
You can always move one digit up, down, left or right. You can't move diagonally!
There a quite a lot of possible ways (or not; I haven't found out yet), here some trivial examples:
> > v
v < <
> > |
The output of the golf-program should look something like the above, I'll try to explain:
Symbols:
Go right
< Go left
^ Go up
v Go down
| End of the way
Example solutions:
(Program output can either be the numbers pressed
in the right order from beginning point to end, or an (ASCII) picture like above)
147852369
569874123
523698741
So if we speak out the example above it would be:
Start at 1, move right to 2, move right to 3, go down to 6, go left to 5, go left to 4, go down to 7, go right to 8 then go right to 9 and we are finished!
Now there are many different ways possible: You could as well start at 5 and go around it in a circle.
So the task would be: Write a program that can compute (using brute-force or whatever) the possible solutions for the numpad problem described above.
(Friendly rethorical question with smiley removed because it made some people think that this is homework)