Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lights Out is a board game in which tiles can be either turned on or turned off. When a tile is pressed, then that tile

Lights Out is a board game in which tiles can be either turned on or turned off. When a tile is pressed, then that tile along with all the horizontally and vertically adjacent tiles and those adjacent to the original adjacent tiles (again, just horizontally and vertically) are inverted. The starting board is an 8x8 grid and all tiles are off.

In the board on the left below, 4 tiles have been turned on; they are indicated by gray squares. In the middle diagram, were getting ready to press the tile marked with an x (at row 4, column 3). The adjacent tiles are labeled with an a, and those adjacent to the a tiles are labeled with a b. The board at the right shows the board after the x tile is pressed.

image text in transcribed

In this problem, you will be given a configuration of the board and a tile to be pressed. Your job is to report the number of tiles that are in the on state after the tile is pressed.

INPUT: There will be 5 lines of input. Each line will contain an integer r indicating the number of rows that have tiles turned on. That will be followed by r strings specifying the row and the columns on that row where tiles are on. Finally, there will be a 2-character string indicating which tile to press. Sample Input #1 shows the input and output for the figures above.

OUTPUT: For each input line, print the number of tiles that are on in the on state after the tile has been pressed.

SAMPLE INPUT: ,SAMPLE OUTPUT:

2, 434, 523, 43 1. 9

1, 58, 58 2. 8

1, 58, 57 3. 11

1, 518, 51 4. 9

3, 32, 44, 56, 54 5. 12

TEST INPUT TEST OUTPUT

1. 1, 11, 22 1. 10

2. 3, 223, 323, 423, 33 2. 7

3. 3, 524, 63, 724, 53 3. 12

4. 4, 2345, 34, 54, 6345, 11 4. 14

5. 4, 118, 435, 635, 818, 54 5. 13

87654321

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

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago