#include <stdint.h>
#include <iostream>
int main() {
// This is our bit mask with the 31 bit set to '1' for initial state
uint64_t state = 1u << 31;
for (int i = 0 ; i < 32 ; i++) {
for (int j = sizeof(uint64_t) * 8 - 1; j >= 0; j--) {
// Here we decide what should be the color of the current cell based on the current state bit mask.
// Bitwise operator is used to accomplish this efficiently
std::cout << char(state >> j & 1 ? '1' : '-');
}
std::cout << '\n';
// This is just the (left, current, right) -> left XOR (current OR right) functioned mentioned previously
// Bitwise operators are used to accomplish this efficiently
state = (state >> 1) ^ (state | state << 1);
}
}