This week's book giveaway is in the Testing forum.We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# an interesting arithmetic, need help.

Kewei Yan
Greenhorn
Posts: 6
this is a table(9*9), how to move from "1" to "81" throuth all the cell, every cell just can be passed once , and the moving direction just can be up or down or left or right.

－ － － － － － － － －
－ － － － － － － － －
－ － 1 － － － － － －
－ － － － － － － － －
－ － － － － － － － －
－ － － － － － － － －
－ － － － － － 81 － －
－ － － － － － － － －
－ － － － － － － － －

Stephen Huey
Ranch Hand
Posts: 618
This definitely sounds like a school assignment that you should be doing on your own!

Kewei Yan
Greenhorn
Posts: 6
Actually, i saw this question in another forum, but there is not any solution. So i put it here ...

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Are you trying to find a solution to the problem, or are you trying to write a program to find a solution? This problem isn't too difficult to solve with some graph paper and a pencil. Just start drawing paths, and try to fill up all the spaces. It may take several attempts, but it really isn't that difficult, IMO.
If you're trying to write a program for this - that will be harder, but definitely a good learning excercise. From position 1, there are 4 possible moves for position 2. From each postion 2, there are 3 possible moves to position 3; from 3, 3 moves to position 4, etc. You can write a program that loops through all these possibilities, keeping track of what positions have been visited. Whenever you detect that a given path intersects itself or exits the board, or hits position 81 prior to the move 80), you needn't investigate that path any further - but keep following the other possibilities. There's still a lot of work to implement this, but that's the basic algorithm I'd used. Good luck...

Ranch Hand
Posts: 70
heres the solution for your Problem
45 46 47 48 49 50 51 52 53
44 61 60 59 58 57 56 55 54
43 62 01 02 03 04 05 06 07
42 63 64 65 66 67 70 71 08
41 40 31 30 29 68 69 72 09
38 39 32 33 28 79 80 73 10
37 36 35 34 27 78 81 74 11
22 23 24 25 26 77 76 75 12
21 20 19 18 17 16 15 14 13

Regards
Karthikeyan
[ January 14, 2004: Message edited by: Karthikeyan Rajendraprasad ]

Kewei Yan
Greenhorn
Posts: 6
Has this problem got only one solution? And how do you get it, by program ?
Thanks!

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Has this problem got only one solution? And how do you get it, by program ?
Thanks!

No, there are many, many solutions.
And how do you get it, by program?
Did you read my previous post?

Kewei Yan
Greenhorn
Posts: 6
Thanks everyone!