On 10 Oct 2003 09:46:44 -0700,

http://www.velocityreviews.com/forums/(E-Mail Removed) (MIke Beam) wrote or

quoted :

>I am trying to solve a problem in Java and need some help. I basically

>need to figure out how many possible 7 digit numbers can be mapped out

>of a number keypad, while moving like any chess peice.
for each chess piece you need to invent a function that provides a

list of relative x,y jumps it can make.

e.g. rook is 0,1 1,0 0,2 2,0 0,3 3,0

Now for each piece for each starting point, you enumerate all moves

continuing till you either get a 7 digit number or jump off the

chessboard. You probably have to dedup your list of 7 digit numbers

since there will be many ways of getting a number. Try a

java.util.BitSet to track your successes.

See

http://mindprod.com/jgloss/combination.html
This is not a good student problem. You as student have no way of

knowing if you did it correctly. The teacher has an easy job -- just

check the number to prove correctness. You can though exercise your

code with one simplified chess piece, on a smaller square to test your

logic.

Some might be tempted to take revenge on this prof by asking a bright

student the magic final answer, then writing gibberish code that gives

that result and let the prof baffle over why it does.

--

Canadian Mind Products, Roedy Green.

Coaching, problem solving, economical contract programming.

See

http://mindprod.com/jgloss/jgloss.html for The Java Glossary.