#include <iostream>
#include <vector>
#include <cstdint>
#include <string>
enum class Cell : std::uint8_t {
Die = 0,
Live = 1 ,
};
std::vector<Cell> MakeVector2() {
std::vector<Cell> R;
std::string S = "*...**.*.***";// find by other person.
for (auto& o :S){
R.push_back((o == '.') ? Cell::Die:Cell::Live);
}
return R;
}
std::vector<Cell> MakeVector() {
std::vector<Cell> R;
std::string S = ".*...**.*.***..";
for (auto& o :S){
R.push_back((o == '.') ? Cell::Die:Cell::Live);
}
return R;
}
bool Show(const std::vector<Cell>& D) {
std::cout << D.size() << ':';
for (auto& o : D) {
std::cout << static_cast<char>((o == Cell::Die) ? '.' : '*');
}
std::cout << std::endl;
return true;
}
std::uint64_t MakeHoge(std::vector<Cell> D,std::size_t L) {
std::vector<Cell> T;
for (std::size_t i = 0; i < L; i++) {
for (std::int64_t j = 0; j < D.size(); j++) {
//if (D[j] == Cell::Die) {
// T.push_back(Cell::Die);
// continue;
//}
if (j == 0) {
T.push_back(static_cast<Cell>(static_cast<std::uint8_t>(D[j]) & static_cast<std::uint8_t>(D[j + 1])));
continue;
}
if (j == D.size() - 1) {
T.push_back(static_cast<Cell>(static_cast<std::uint8_t>(D[j]) & static_cast<std::uint8_t>(D[j - 1])));
continue;
}
if (((D[j - 1] == D[j + 1]) && (D[j-1] == Cell::Live)) &&( D[j]== Cell::Die)) {
T.push_back(Cell::Live);
continue;
}
if ((D[j - 1] != D[j + 1]) && D[j] == Cell::Live) {
T.push_back(Cell::Live);
}
else {
T.push_back(Cell::Die);
}
}
if (D == T) {
return i;
}
else {
Show(T);
D = T;
T.clear();
}
}
return L;
}
int main() {
std::vector<Cell> D = MakeVector();
Show(D);
auto R=MakeHoge(D, 100);
std::cout << "Count:" << R+1 << std::endl;
return 0;
}