You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.1 KiB

#!/usr/bin/env python3
import sys
from copy import deepcopy
def cprint(cucs):
for l in cucs:
print(''.join(l))
print('\n')
def step(cucs):
nc = deepcopy(cucs)
for y,l in enumerate(cucs):
for x,c in enumerate(l):
if c == '>':
if cucs[y][(x+1)%len(l)] == '.':
nc[y][x] = '.'
nc[y][(x+1)%len(l)] = '>'
cucs = deepcopy(nc)
for y,l in enumerate(cucs):
for x,c in enumerate(l):
if c == 'v':
if cucs[(y+1)%len(cucs)][x] == '.':
nc[y][x] = '.'
nc[(y+1)%len(cucs)][x] = 'v'
return nc
if __name__ == '__main__':
cucs = [list(line.strip('\n')) for line in open(sys.argv[1])]
# challenge 1
nc = []
i = 0
while nc != cucs:
print(i)
i += 1
cprint(nc)
cucs = deepcopy(nc) if nc != [] else cucs
nc = step(cucs)
res1 = str(i)
print("challenge 1:" + "\n" + res1 + "\n")
# challenge 2
res2 = "doesn't exist :)"
print("challenge 2:" + "\n" + res2 + "\n")