aspose file tools*
The moose likes Java in General and the fly likes an interesting arithmetic, need help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "an interesting arithmetic, need help." Watch "an interesting arithmetic, need help." New topic
Author

an interesting arithmetic, need help.

Kewei Yan
Greenhorn

Joined: Jan 08, 2004
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 - -
- - - - - - - - -
- - - - - - - - -
I am so puzzled , please help.Thanks.
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
This definitely sounds like a school assignment that you should be doing on your own!
Kewei Yan
Greenhorn

Joined: Jan 08, 2004
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

Joined: Jan 30, 2000
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...


"I'm not back." - Bill Harding, Twister
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
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 ]

Karthikeyan<br />SCJP 1.4, SCWCD.
Kewei Yan
Greenhorn

Joined: Jan 08, 2004
Posts: 6
To: Karthikeyan Rajendraprasad
Has this problem got only one solution? And how do you get it, by program ?
Thanks!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
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

Joined: Jan 08, 2004
Posts: 6
Thanks everyone!
 
Consider Paul's rocket mass heater.
 
subject: an interesting arithmetic, need help.