Question: Write a program that, given such a grid, finds a solution satisfying the stated criteria. The input will come from the keyboard. Error check for

Write a program that, given such a grid, finds a solution satisfyingthe stated criteria. The input will come from the keyboard. Error checkWrite a program that, given such a grid, finds a solution satisfying the stated criteria. The input will come from the keyboard. Error check for positive board sizes from 4 to 15 only and check for a square matrix on input. Assume only one solution to a board. Let the user have the option of running the program as many times if desired (check input). Output the solved grid with the erased cells with @'s and two spaces between each value. Use any data structure of your choice. Refer to the sample output below.

5 **). Hitori is a simple puzzle game played on an N * N grid of positive integers. The idea is simply to cross out integers in the grid (as few as possible) so that: Any given number appears at most once in any given column or row; COSC 2436 520 The remaining (unerased) numbers form a single connected group of squares, so that any unerased square is reachable from any other unerased square by a path of unerased squares that are adjacent horizontally or vertically; If a square is erased, its adjacent horizontal and vertical neighbors are not erased. So, given the initial grid (1), below, grid (2)is a solution. The other grids are not solutions for various reasons: (3)has two adjacent squares erased, (4)erases more squares than needed, and (5) breaks the unerased squares into unconnected groups. Of course, (1)itself is not a solution because it has duplicate numbers in several rows and columns. 1 2 5 3 4 2 2 2 3 6 3 5 2 4 5 1 - (1) 1 2 5 3 4 2 2 2 36 3 5 2 4 5 1 (2) 1 2 5 3 1 2 5 3 1 2 5 3 4 2 2 2 4 2 2 2 4 2 2 2 36 35 36 35 36 35 2 4 5 1 2 4 5 1 2 4 5 1 (3) (4) (5) Write a program that, given such a grid, finds a solution satisfying the stated criteria. The input will come from the keyboard. Error check for positive board sizes from 4 to 15 only and check for a square matrix on input. Assume only one solution to a board. Let the user have the option of running the program as many times if desired (check input). Output the solved grid with the erased cells with a's and two spaces between each value. Use any data structure of your choice. Refer to the sample output below. Sample Run: Solved board: Enter the board size: 8 Enter a Hitori puzzle: 4 81 6 3 2 5 7 3 6 7 2 1 6 5 4 2 3 4 8 2 8 6 1 4 1 6 5 7 7 3 5 7 2 3 1 8 5 1 2 3 5 6 7 3 1 8 4 6 4 2 3 5 4 7 8 8 7 1 4 2 3 5 6 @ 3 @ 4 7 @ 6 8 8 6 3 1 @ 5 @ 7 @ 7 4 @ 3 6 2 1 6 2 @ 5 @ 7 3 4 3 1 2 7 8 @ 5 @ 2 @ 8 @ 5 1 4 3 @ 5 6 3 1 8 7 @ 7 4 1 @ 2 @ 8 6 Run again (Y/N)? y Enter the board size: 4 Enter a Hitori puzzle: Solved board: 1 253 4 2 2 2 3635 2 4 5 1 1 4 @ 2 2 @ 6 4 5 2 3 @ 3 @ 5 1 Run again (Y/N)? N Name the program: Hitorixx.java or Hitorixx.cpp, where XX are your initials 5 **). Hitori is a simple puzzle game played on an N * N grid of positive integers. The idea is simply to cross out integers in the grid (as few as possible) so that: Any given number appears at most once in any given column or row; COSC 2436 520 The remaining (unerased) numbers form a single connected group of squares, so that any unerased square is reachable from any other unerased square by a path of unerased squares that are adjacent horizontally or vertically; If a square is erased, its adjacent horizontal and vertical neighbors are not erased. So, given the initial grid (1), below, grid (2)is a solution. The other grids are not solutions for various reasons: (3)has two adjacent squares erased, (4)erases more squares than needed, and (5) breaks the unerased squares into unconnected groups. Of course, (1)itself is not a solution because it has duplicate numbers in several rows and columns. 1 2 5 3 4 2 2 2 3 6 3 5 2 4 5 1 - (1) 1 2 5 3 4 2 2 2 36 3 5 2 4 5 1 (2) 1 2 5 3 1 2 5 3 1 2 5 3 4 2 2 2 4 2 2 2 4 2 2 2 36 35 36 35 36 35 2 4 5 1 2 4 5 1 2 4 5 1 (3) (4) (5) Write a program that, given such a grid, finds a solution satisfying the stated criteria. The input will come from the keyboard. Error check for positive board sizes from 4 to 15 only and check for a square matrix on input. Assume only one solution to a board. Let the user have the option of running the program as many times if desired (check input). Output the solved grid with the erased cells with a's and two spaces between each value. Use any data structure of your choice. Refer to the sample output below. Sample Run: Solved board: Enter the board size: 8 Enter a Hitori puzzle: 4 81 6 3 2 5 7 3 6 7 2 1 6 5 4 2 3 4 8 2 8 6 1 4 1 6 5 7 7 3 5 7 2 3 1 8 5 1 2 3 5 6 7 3 1 8 4 6 4 2 3 5 4 7 8 8 7 1 4 2 3 5 6 @ 3 @ 4 7 @ 6 8 8 6 3 1 @ 5 @ 7 @ 7 4 @ 3 6 2 1 6 2 @ 5 @ 7 3 4 3 1 2 7 8 @ 5 @ 2 @ 8 @ 5 1 4 3 @ 5 6 3 1 8 7 @ 7 4 1 @ 2 @ 8 6 Run again (Y/N)? y Enter the board size: 4 Enter a Hitori puzzle: Solved board: 1 253 4 2 2 2 3635 2 4 5 1 1 4 @ 2 2 @ 6 4 5 2 3 @ 3 @ 5 1 Run again (Y/N)? N Name the program: Hitorixx.java or Hitorixx.cpp, where XX are your initials

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!