I need help with my assignemnt... cannot seem to put things together. Game of li
ID: 3769246 • Letter: I
Question
I need help with my assignemnt... cannot seem to put things together.
Game of life 2-d arrays assignment in c++ language and need three separate files, incudes header file, main file, client file. I already did most of the program but it doesn't work. Can u run the program and fix it for me? Thank you
Your task is to write a program that plays the game of life. This game is a computer simulation of the life and death events in a population of single-cell organisms. Each position in a two-dimensional grid (Petri dish) can support one cell. The program determines whether each position will be able to support life in the next generation.
The grid of cells is represented by a two-dimensional array. The starting grid is generation 0 and is read from a supplied input file. Most positions in the grid have 8 neighbors like the center square in a tic-tac-toe game. The four corner positions have only 3 neighbors each. The remaining positions around the edge of the grid have 5 neighbors each. The rules for the state of each position in the next generation of the grid are as follows:
If the cell is currently empty:
If the cell has exactly three living neighbors, it will come to life in the next generation.
If the cell has any other number of living neighbors, it will remain empty.
If the cell is currently living:
If the cell has one or zero living neighbors, it will die of loneliness in the next generation.
If the cell has four or more living neighbors, it will die of overcrowding in the next generation.
If the cell has two or three neighbors, it will remain living.
All births and deaths occur simultaneously. This point is critical to the correct result.
The following three webpages are also available: the data file, the correct output, and the output including intermediate generations. The last webpage is available to help you debug your code.
The data file supplies the data for generation 0. Each line of data gives a pair of coordinates (row# column#) for a living cell in the original grid. Assume that every number in the text file is between 0 and 19. All other grid positions are empty. Please name your input file "life.txt".
After your program has created the two-dimensional array that represents generation 0, your program must allow life to proceed for the number of generations specified by the user. Start with five generations. Your program should then display a grid on the screen to show the final results. Use a star (*) to represent a live cell and a space to represent a dead cell. After the grid, display the following statistical information:
The number of living cells in the entire board.
The number of living cells in row 10.
The number of living cells in column 10.
Please make sure that your output matches the correct output exactly.
Your first step will be to create a class named boolMatrix for storing and processing a two-dimensional array of bool values. The class should be saved in a specification file and an implementation file. Your client program must use this class rather than declaring its own arrays. You must not use any arrays in your client program.
You'll be defining two constants in your class, but you need to know a little bit about "static" members of classes first. With all of the class members we have used so far, each class object that the client declares has its own copy. With a "static" member, there is just one copy of the member that all objects share. Since constants don't change, it makes sense to just have one copy that all objects share. So, when you declare constants, you must make them static.
In the public area of your class you must define two public constants, NUM_ROWS AND NUM_COLS. I'll give you this code for free:
There are a few places in the descriptions of the member functions below where you are required to use "assert()". Here is a quick tutorial on using assert. First, you need to place #include at the top of your implementation file. Then you can call a function named assert(), placing a logical expression inside the parentheses. If the logical expression is true, nothing happens. If the logical expression is false, the program exits and an error message is printed. For example, your assert might look like this:
Keep in mind as you write the class that it is to be completely unrelated to the game of Life. The class should not mention anything about life, cells, neighbors, etc. The class will have exactly one private data member that is an array of bool. The class will have seven member functions:
default constructor: initialize all of the array elements to false
get: return the current contents of a single array element. Use arguments to indicate the row and column of the array element that should be returned. This function must use assert to exit the program if the row or column is out-of-bounds. You will receive a 0 on the assignment if this is not implemented.
set: set the contents of a single array element. Use arguments to indicate the row and column of the array element that should be set, and the value to which it should be set. This function must use assert to exit the program if the row or column is out-of-bounds. You will receive a 0 on the assignment if this is not implemented.
rowcount: return the number of true values that exist in any given row. This function must use assert to exit the program if the row is out-of-bounds. You will receive a 0 on the assignment if this is not implemented.
colcount: return the number of true values that exist in any given column. This function must use assert to exit the program if the column is out-of-bounds. You will receive a 0 on the assignment if this is not implemented.
totalcount: return the number of true values that exist in the entire array
print: display the contents of the array, including the row and column indices (see the posted correct output). For each element of the array, a true value must be displayed as an asterisk ("*") and a false value must be displayed as a space. This member function is the only one that displays output.
Use const to indicate const functions and unchangeable reference parameters whenever possible.
In this program, a minimum of five functions is required in addition to main(). In my solution there are seven functions besides main(). Remember our discussions about stepwise refinement, value-returning vs. void functions, and value parameters vs. reference parameters.
The only documentation required is the initial file documentation for each of the three files. Note that this means you must provide pre/post conditions in your header file.
Hints
Use iterative development.
Keep straight that the array is a data member within the class object and must be accessed accordingly.
You should definitely have a function named countNeighbors() in your client program. I'm providing that function here. Note that it calls another function named "onGrid" that you will need to provide.
Explanation / Answer
Here is the code according to the specification in the question. Please see the sample input and output. Please don't forget to rate the answer if it helped. Thank you very much.
BoolMatrix.h
class BoolMatrix
{
public:
static const int NUM_ROWS = 20; //constants in the class
static const int NUM_COLS = 20;
BoolMatrix();//default constructor
bool get(int row, int col) const;//gets the value in the matrix locatio row,col
void set(int row, int col, bool value); //set the value at location row, col to specifid bool value
int rowcount(int row); // returns the number of true values in the specified row
int colcount(int col); //returns the number of true values in the specified col
int totalcount();//returns total number of true values in the entire matrix
void print();//prints the matrix on console, true values displayed as * and false as a space
private:
bool matrix[NUM_ROWS][NUM_COLS]; //matrix to hold bool values
};
BoolMatrix.cpp
#include "BoolMatrix.h"
#include <cassert>
#include <iostream>
using namespace std;
BoolMatrix::BoolMatrix()//default constructor
{
//initialize all positions to false
for(int i = 0; i < NUM_ROWS; i++)
for(int j = 0; j< NUM_COLS; j++)
matrix[i][j] = false;
}
bool BoolMatrix::get(int row, int col) const//gets the value in the matrix locatio row,col
{
assert(row >= 0 && row< NUM_ROWS);
assert(col >= 0 && col< NUM_COLS);
return matrix[row][col];
}
void BoolMatrix::set(int row, int col, bool value) //set the value at location row, col to specifid bool value
{
assert(row >= 0 && row< NUM_ROWS);
assert(col >= 0 && col< NUM_COLS);
matrix[row][col] = value;
}
int BoolMatrix::rowcount(int row) // returns the number of true values in the specified row
{
assert(row >= 0 && row< NUM_ROWS);
int count = 0;
for(int col = 0; col < NUM_COLS; col++)
{
if(matrix[row][col])
count++;
}
return count;
}
int BoolMatrix::colcount(int col) //returns the number of true values in the specified col
{
assert(col >= 0 && col< NUM_COLS);
int count = 0;
for(int row = 0; row < NUM_ROWS; row++)
{
if(matrix[row][col])
count++;
}
return count;
}
int BoolMatrix::totalcount()//returns total number of true values in the entire matrix
{
int count = 0;
for(int i = 0; i < NUM_ROWS; i++)
count += rowcount(i);
return count;
}
void BoolMatrix::print()//prints the matrix on console, true values displayed as * and false as a space
{
for(int i = 0; i < NUM_ROWS; i++)
{
cout<<" ";
for(int j = 0; j < NUM_COLS; j++)
{
if(matrix[i][j])
cout<<"[*] ";
else
cout<<"[ ] ";
}
}
cout<<endl;
cout<<"The total number of living cells is "<<totalcount()<<endl;
cout<<"The number of cells living in row 10 is "<<rowcount(10)<<endl;
cout<<"The number of cells living in col 10 is "<<colcount(10)<<endl<<endl;
}
main.cpp
#include "BoolMatrix.h"
#include <iostream>
#include <fstream>
using namespace std;
bool LoadFromFile(string filename, BoolMatrix &matrix);
int OnGrid(int row, int col);
void Evolve(const BoolMatrix &oldGen, BoolMatrix &newGen);
int CountNeighbors(const BoolMatrix &life, int row, int col);
int main()
{
string filename;
BoolMatrix life;
int n;
cout<<"Enter a file name to load: ";
cin>>filename;
if(LoadFromFile(filename, life))
{
cout<<"How many generations you want? ";
cin>>n;
cout<<"Generation No. 0"<<endl;
life.print();
for(int i = 1; i <= n; i++)
{
BoolMatrix newGen;
Evolve(life, newGen);
cout<<"Generation No. "<<i<<endl;
newGen.print();
life = newGen; //for next iteration, the newGeneration becomes the starting point
}
}
cout<<" Program terminated."<<endl;
}
//loads a generation from a file. Expected format for file is data only for live cells. Each line will hava rowvalue space colvalue if that
//cell is living. Dead cells are not represented in the file
bool LoadFromFile(string filename, BoolMatrix &matrix)
{
ifstream infile(filename.c_str());
int row, col;
if(!infile.is_open())
{
cout<<"Could not open input file: "<<filename<<endl;
return false;
}
while(infile>>row)
{
infile>>col;
matrix.set(row,col,true);
}
infile.close();
return true;
}
//checks if the row, col location is within the grid position based on the NUM_ROWS and NUM_COLS in BoolMatrix
int OnGrid(int row, int col)
{
if(row >= 0 && row < BoolMatrix::NUM_ROWS && col >= 0 && col <BoolMatrix::NUM_COLS)
return true;
else
return false;
}
int CountNeighbors(const BoolMatrix& life, int row, int col) {
int count = 0;
for (int rowCount = row-1; rowCount <= row+1; rowCount++){
for (int colCount = col-1; colCount <= col+1; colCount++){
if (OnGrid(rowCount, colCount) && life.get(rowCount, colCount)){
count++;
}
}
}
if (life.get(row, col)){ //because we counted life[row][col] as a neighbor
count--;
}
return count;
}
void Evolve(const BoolMatrix &oldGen, BoolMatrix &newGen)
{
int neighbours;
for(int i = 0; i < BoolMatrix::NUM_ROWS; i++)
{
for(int j = 0; j < BoolMatrix::NUM_COLS; j++)
{
neighbours = CountNeighbors(oldGen, i, j);
if(oldGen.get(i,j)) //if its a live cell in old generation
{
if(neighbours == 2 || neighbours==3)
newGen.set(i, j, true); //when a live cell has less than 2 it dies of loneliness and greater than 3 dies of overcrowding
else
newGen.set(i, j, false);
}
else //its a dead cell in old generation
{
if(neighbours == 3) //a dead cell comes to life if it has exactly 3 living neighbours
newGen.set(i, j, true);
}
}
}
}
sample input file contents
0 0
0 5
0 9
0 19
1 6
1 14
1 16
2 4
2 7
2 11
2 14
2 15
2 16
2 18
3 2
3 5
3 9
3 10
3 17
3 19
4 0
4 3
4 5
4 9
5 2
5 3
5 5
5 15
5 16
5 17
6 5
6 6
6 10
6 11
6 13
6 14
6 17
6 18
7 6
7 8
7 14
7 16
8 1
8 5
8 8
8 10
8 17
9 3
9 4
9 6
9 7
10 0
10 9
10 19
11 1
11 2
11 3
11 5
11 7
11 8
11 14
11 17
11 19
12 4
12 5
12 6
12 8
13 0
13 1
13 7
13 10
13 11
13 14
13 15
13 16
13 17
13 18
14 2
14 11
14 13
14 15
14 17
14 19
15 11
15 13
15 18
16 1
16 2
16 5
16 8
16 17
17 5
17 6
18 6
18 16
18 18
19 0
19 3
19 4
19 7
output
Enter a file name to load: lifedata.txt
How many generations you want? 5
Generation No. 0
[*] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [*] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [*] [*] [*] [ ] [*] [ ]
[ ] [ ] [*] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*]
[*] [ ] [ ] [*] [ ] [*] [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] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [ ]
[*] [ ] [ ] [*] [*] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 100
The number of cells living in row 10 is 3
The number of cells living in col 10 is 4
Generation No. 1
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [*] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [*] [ ] [*] [ ]
[ ] [ ] [ ] [*] [ ] [*] [*] [ ] [*] [*] [*] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [ ]
[ ] [*] [ ] [*] [ ] [*] [*] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ]
[ ] [ ] [*] [*] [ ] [*] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [*] [*] [*] [ ]
[ ] [ ] [ ] [ ] [*] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [ ] [*] [*] [*] [*] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [*] [*] [*] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ]
[ ] [*] [*] [*] [ ] [*] [ ] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ]
[*] [ ] [ ] [*] [*] [*] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ]
[ ] [*] [ ] [ ] [ ] [*] [*] [*] [ ] [ ] [*] [*] [*] [ ] [*] [*] [ ] [*] [*] [ ]
[ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [ ] [*] [ ] [ ] [ ] [*]
[ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [*] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ]
[ ] [ ] [ ] [ ] [*] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 112
The number of cells living in row 10 is 3
The number of cells living in col 10 is 6
Generation No. 2
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ]
[ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [*] [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] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 98
The number of cells living in row 10 is 2
The number of cells living in col 10 is 6
Generation No. 3
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [*] [ ] [ ] [*] [*] [ ] [ ] [*] [*]
[ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [*] [ ] [ ] [*] [ ] [*] [*]
[ ] [ ] [*] [ ] [ ] [ ] [*] [*] [ ] [*] [ ] [ ] [ ] [*] [*] [*] [ ] [ ] [ ] [*]
[ ] [ ] [*] [*] [*] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*]
[ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [*] [*] [*] [ ] [*] [*] [ ] [*] [*] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [*] [*] [*] [*] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[*] [*] [ ] [ ] [*] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[*] [*] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [*] [ ] [*] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [*] [*] [ ] [*] [*] [ ]
[ ] [ ] [*] [ ] [ ] [*] [*] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [*] [*]
[ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [*] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [*]
[*] [*] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [ ] [*] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 95
The number of cells living in row 10 is 4
The number of cells living in col 10 is 3
Generation No. 4
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [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] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 95
The number of cells living in row 10 is 3
The number of cells living in col 10 is 5
Generation No. 5
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [*] [*] [*] [ ] [ ] [*] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [*] [*] [ ] [*] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [*] [ ] [*] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ]
[ ] [ ] [ ] [ ] [*] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [*] [*] [*] [ ] [ ] [*] [ ]
[ ] [*] [*] [ ] [*] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [*] [*] [*] [ ] [*]
[ ] [ ] [ ] [ ] [*] [ ] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [ ]
[ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [*] [*] [ ] [ ] [ ]
[*] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [*] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [ ] [ ] [*] [ ]
[*] [*] [ ] [ ] [ ] [ ] [*] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*]
[ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [*] [ ] [*] [*] [ ] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [*] [ ] [ ] [ ] [*] [ ] [ ] [ ] [*] [*] [*]
[ ] [*] [*] [ ] [ ] [ ] [*] [*] [*] [ ] [ ] [ ] [ ] [ ] [ ] [*] [*] [ ] [*] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [*] [ ] [*] [*]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
The total number of living cells is 95
The number of cells living in row 10 is 3
The number of cells living in col 10 is 1
Program terminated.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.