Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 (**). Hitori is a simple puzzle game played on an N N grid of positive integers. The idea is simply to cross out integers

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; 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.cpp, where XX are your initials.

Program in C++image text in transcribedimage text in transcribed

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; 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 36 35 36 35 36 35 36 35 36 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 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 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 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 2 5 3 4 2 2 2 3 6 3 5 1 4 2 5 3 @ 2 @ 6 35 4 @ 1 Updated February 5, 2020 2 4 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; 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 36 35 36 35 36 35 36 35 36 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 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 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 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 2 5 3 4 2 2 2 3 6 3 5 1 4 2 5 3 @ 2 @ 6 35 4 @ 1 Updated February 5, 2020 2 4 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago