repl.it
@YuzhiEntity/

Behaulken

Python

No description

fork
loading
Files
  • main.py
main.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
row1 = input("Enter first five bit list:").split()
row2 = input("Enter second five bit list:").split()
row3 = input("Enter third five bit list:").split()
row4 = input("Enter fourth five bit list:").split()
row5 = input("Enter fifth five bit list:").split()
grid = [row1, row2, row3, row4, row5]
newcell = []
print("\nCurrent grid:")
print(" ".join(row1))
print(" ".join(row2))
print(" ".join(row3))
print(" ".join(row4))
print(" ".join(row5))
while True:
  x = input("Type space followed by enter to behaulk. Press enter to stop.")
  if x == "":
    break
  else:
    for rownum, every in enumerate(grid):
      for colnum, setsuna in enumerate(every):
        setsuna = int(setsuna)
        if rownum == 0:
          if colnum == 0:
            if setsuna == 0:
              if grid[1][0] == 1 and grid[1][1] == 1 and grid[0][1] == 1:
                newcell.append([0, 0, 1])
            else:
              if grid[1][0] + grid[1][1] + grid[0][1] in [2, 3]:
                pass
              else:
                newcell.append([0, 0, 0])
          elif colnum == 4:
            if setsuna == 0:
              if grid[0][3] == 1 and grid[1][3] == 1 and grid[1][4] == 1:
                newcell.append([0, 4, 1])
            else:
              if grid[0][3] + grid[1][3] + grid[1][4] in [2, 3]:
                pass
              else:
                newcell.append([0, 4, 0])
          else:
            if setsuna == 0:
              if grid[0][colnum-1] + grid[0][colnum+1] + grid[1][colnum] + grid[1][colnum-1] + grid[1][colnum+1] == 3:
                newcell.append([0, colnum, 1])
            else:
              if grid[0][colnum-1] + grid[0][colnum+1] + grid[1][colnum] + grid[1][colnum-1] + grid[1][colnum+1] in [2, 3]:
                pass
              else:
                newcell.append([0, colnum, 0])
        elif rownum == 4:
          if colnum == 0:
            if setsuna == 0:
              if grid[3][0] == 1 and grid[3][1] == 1 and grid[3][1] == 1:
                newcell.append([3, 0, 1])
            else:
              if grid[3][0] + grid[1][1] + grid[0][1] in [2, 3]:
                pass
              else:
                newcell.append([3, 0, 0])
          elif colnum == 4:
            if setsuna == 0:
              if grid[3][4] == 1 and grid[3][3] == 1 and grid[4][3] == 1:
                newcell.append([4, 4, 1])
            else:
              if grid[3][4] + grid[3][3] + grid[4][3] in [2, 3]:
                pass
              else:
                newcell.append([4, 4, 0])
          else:
            if setsuna == 0:
              if grid[4][colnum-1] + grid[4][colnum+1] + grid[3][colnum] + grid[3][colnum-1] + grid[3][colnum+1] == 3:
                newcell.append([0, colnum, 1])
            else:
              if grid[4][colnum-1] + grid[4][colnum+1] + grid[3][colnum] + grid[3][colnum-1] + grid[3][colnum+1] in [2, 3]:
                pass
              else:
                newcell.append([0, colnum, 0])
        else:
          if colnum == 0:
            if setsuna == 0:
              if grid[rownum+1][0] + grid[rownum+1][1] + grid[rownum][1] + grid[rownum-1][0] + grid[rownum-1][1] == 3:
                newcell.append([rownum, 0, 1])
            else:
              if grid[rownum+1][0] + grid[rownum+1][1] + grid[rownum][1] + grid[rownum-1][0] + grid[rownum-1][1] in [2, 3]:
                pass
              else:
                newcell.append([rownum, 0, 0])
          elif colnum == 4:
            if setsuna == 0:
              if grid[rownum+1][4] + grid[rownum+1][3] + grid[rownum][3] + grid[rownum-1][4] + grid[rownum-1][3] == 3:
                newcell.append([rownum, 4, 1])
            else:
              if grid[rownum+1][4] + grid[rownum+1][3] + grid[rownum][3] + grid[rownum-1][4] + grid[rownum-1][3] in [2, 3]:
                pass
              else:
                newcell.append([rownum, 4, 0])
          else:  
            if setsuna == 0:
              if grid[rownum-1][colnum-1] + grid[rownum-1][colnum] + grid[rownum-1][colnum+1] + grid[rownum][colnum-1] + grid[rownum][colnum+1] + grid[rownum+1][colnum-1] + grid[rownum+1][colnum] + grid[rownum+1][colnum+1] == 3:
                newcell.append([rownum, colnum, 1])
            else:
              if grid[rownum-1][colnum-1] + grid[rownum-1][colnum] + grid[rownum-1][colnum+1] + grid[rownum][colnum-1] + grid[rownum][colnum+1] + grid[rownum+1][colnum-1] + grid[rownum+1][colnum] + grid[rownum+1][colnum+1] in [2, 3]:
                pass
              else:
                newcell.append([rownum, colnum, 1])
    for al in newcell:
      grid[al[0]][al[1]] = al[2]
    print(grid[0])
    print(grid[1])
    print(grid[2])
    print(grid[3])
    print(grid[4])