Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

how do i go about programming this:(JAVA) You have to put the numbers 1-8 in the eight available cells in such a way that no number borders a consecutive number, even diagonally.

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
1 Attachment
I would create a map of each cell and its adjacent cells. Then make sure that the number in the cell does not have a consecutive number in any of the adjacent cells. Create a loop to try the different combinations.
The mathematical solution can be found here: http://www.geeksforgeeks.org/forum/topic/fill-numbers-puzzle

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

you can write it as a backtracking problem - label boxes to fill from 0-7, and successively try to put a number in it: while (boxnumber < 8){ // if 8, are done ...put unused number in box ...test conditions ...if ok boxnumber += 1 // on to the next ...if not erase last try if more numbers to try, try next else backup a level, erase number there, and try next number the annoying part is keeping track of everything.
my sleazy python program finds 16 solutions

Not the answer you are looking for?

Search for more explanations.

Ask your own question