1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from sys import stdout
import numpy as np

SIZE = 100
def print_img(image: list[str]):
    assert len(image) <= SIZE
    for line in image:
        assert len(line) <= SIZE
        print(line+"0"*(SIZE-len(line)))
    for _ in range(SIZE - len(image)):
        print("0"*SIZE)

def print_tab(t):
    for line in t:
        for field in line:
            stdout.write(str(field))
        stdout.write("\n")


# print_img([
#     "011110",
#     "100100",
#     "110100",
#     "100000",
#     "111100",
# ])

tab = np.zeros((SIZE, SIZE), dtype=int)
tab[0, 1:SIZE] = 1
tab[1:SIZE, 0] = 1

for i in range(2, SIZE, 2):
    tab[i, 0:i] = 1

for i in range(3, SIZE, 2):
    tab[0:i, i] = 1

print_tab(tab)

# def apply_rule(grid):
#     new_grid = np.copy(grid)
#     size = grid.shape[0]
#     
#     for i in range(size - 1):
#         for j in range(size - 1):
#             square = grid[i:i+2, j:j+2]
#             ones = np.argwhere(square == 1)
#             
#             if len(ones) == 2:
#                 if abs(ones[0][0] - ones[1][0]) == 1 and abs(ones[0][1] - ones[1][1]) == 1:
#                     new_grid[i:i+2, j:j+2] = 1 - square  
#     
#     return new_grid
# 
# seen_states = set()
# step_count = 0
# grid = tab.copy()
# 
# while True:
#     if str(grid) in seen_states:
#         print(f'Koniec po sekundzie: {len(seen_states)}')
#         break
#     
#     seen_states.add(str(grid))
#     grid = apply_rule(grid)
#     step_count += 1