-
Notifications
You must be signed in to change notification settings - Fork 0
/
stenvatten.py
62 lines (50 loc) · 1.18 KB
/
stenvatten.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
height, breath = [int(n) for n in input().split()]
matrice = []
def print_cascade(matrice):
for row in matrice:
print(row)
print()
for i in range(height):
plan = input()
matrice.append(list(plan))
def update_matrice(matrice):
changed = False
for i in range(height - 1):
for j in range(breath):
if matrice[i][j] == 'V':
if matrice[i + 1][j] == '.':
matrice[i + 1][j] = 'V'
changed = True
if matrice[i + 1][j] == '#':
if ((j - 1) >= 0) and matrice[i][j - 1] == '.':
matrice[i][j - 1] = 'V'
changed = True
if (j + 1 < breath) and matrice[i][j + 1] == '.':
matrice[i][j + 1] = 'V'
changed = True
return changed
while update_matrice(matrice):
pass
for row in matrice:
print(''.join(row))
'''
5 7
...V...
.......
.......
...#...
..###..
12 14
....V...V.....
..............
..............
..............
...#########..
.......#......
.......#.#....
.......#####..
........###...
........#.#...
........#.#...
##############
'''