Question
c++ or java HELP!! ASAP 5 (**). Hitori is a simple puzzle game played on an N N grid of positive integers. The idea is
c++ or java HELP!! ASAP
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 S20 7 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 1 2 5 3 1 2 5 3 1 2 5 3 1 2 5 3 4 2 2 2 4 2 2 2 4 2 2 2 4 2 2 2 4 2 2 2 3 6 3 5 3 6 3 5 3 6 3 5 3 6 3 5 3 6 3 5 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 (1) (2) (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 @'s and two spaces between each value. Use any data structure of your choice. Refer to the sample output below. Sample Run: Enter the board size: 8 Enter a Hitori puzzle: 4 8 1 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 Enter the board size: 4 Enter a Hitori puzzle: 1 2 5 3 4 2 2 2 3 6 3 5 2 4 5 1 Solved board: @ 8 @ 6 3 2 @ 7 3 6 7 2 1 @ 5 4 @ 3 4 @ 2 8 6 1 4 1 @ 5 7 @ 3 @ 7 @ 3 @ 8 5 1 2 @ 5 6 7 @ 1 8 @ 6 @ 2 3 5 4 7 8 8 7 1 4 @ 3 @ 6 Run again (Y/N)? y Solved board: 1 2 5 3 4 @ 2 @ @ 6 3 5 2 4 @ 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 S20 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 36 35 24 51 (1) 1 2 5 3 1 2 5 3 1 2 5 3 1 2 5 3 4 3 23 4 2 2 2 4 3 23 43 23 36 35 36 35 36 35 36 35 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 (2) (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 e'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: 2 4 8 1 6 3 2 5 7 36 7 2 1 6 5 4 2 3 4 8 2 8 6 1 4 1 6 5 7 7 3 5 72 31 8 5 1 2 3 5 6 7 31 84 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 @ 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 2 5 3 4 2 2 2 36 35 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 initialsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started