Question: We are interested in getting 7 digit phone number by watching a chess piece (rook) traverse a board with numbers on each board position.
Given a 3 by 3 board that looks like this.
1 2 3
4 5 6
7 8 9
And assuming that a rook starts on position 4, write a function which provides all of the combinations of 7 digit numbers which start with 4.
For example:
456-3214 would be generated when the rook moves
{ right one, right one, up one, left one, left one, down one }
464-6464 would be generated when the rook moves
{right two, left two, right two, left two, right two, left two }
I couldnt come up with a solution. Any ideas ?