Question
C++ ONLY PLEASE DEMOLITION.TXT CONTENTS SHOWN BELOW In the game demolition, one can remove all of the same type of squares that are adjacent in
C++ ONLY PLEASE
DEMOLITION.TXT CONTENTS SHOWN BELOW
In the game demolition, one can remove all of the same type of squares that are adjacent in a row, either vertically, horizontally or diagonally. The more squares that are in the row, the more points one earns. Your job is to write a program that takes a board of square tiles as input and determines the best set of tiles blow up.
For example if a 5 x 5 board was the following
[ a b c a b ]
[ a c b a c ]
[ c b a b c ]
[ a c b c b ]
[ b a a b b ]
Then the best move would be demolish the 4 bs at (0, 1), (1, 2), (2, 3), and (3, 4)
For example in a 3 x 5 board was the following:
[ a b c a b ]
[ b a a a a ]
[ c b a b c ]
Then the best move would be demolish the 4 as at (1 1), (1, 2), (1, 3), and (1,4)
Input:
The input all be from the keyboard and will contain multiple boards. Alternatively, all the numbers can be input from demolition.txt, which can be found at Canvas.
Each board is preceded by 2 integers r and c denoting the number of rows and columns of your board. Both r and c will be less than 501.
The next r lines will contain c characters each separated by a space. The end of input will be denoted by r = c = 0.
Output:
Each test case should generate one line of the form
Board b has s squares in a row of letter c.
where b is the number of the board (starting at one) and you supply the correct values for s and c.
Sample Input
5 5
a b c a b
a c b a c
c b a b c
a c b c b
b a a b b
3 5
a b c a b
b a a a a
c b a b c
0 0
Sample Output
Board 1 has 4 squares in a row of letter b.
Board 2 has 4 squares in a row of letter a.
Hints:
Process the input as soon as you get it. My screen at the end actually looked like:
5 5
a b c a b
a c b a c
c b a b c
a c b c b
b a a b b
Board 1 has 4 squares in a row of letter b.
3 5
a b c a b
b a a a a
c b a b c
Board 2 has 4 squares in a row of letter a.
0 0
Press any key to continue . . .
If your program has no functions, it will get a lower grade
If your program has global variables, it will get a lower grade
A function should fit on the screen. It should not be 1 line long.
You should write a routine to print out your board to help debug it.
Your memo is written to someone who is your level but has not seen the problem
After reading your memo, the user should be able to generate valid input to your program and predict the output.
You have to test your code using at the cases the aforementioned sample inputs.
3 5 a bca b ba a a a
Step 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