57 lines
1.1 KiB
Python
57 lines
1.1 KiB
Python
#!/bin/python3
|
|
|
|
import sys
|
|
from pprint import pprint
|
|
|
|
input_f = sys.argv[1]
|
|
|
|
result = 0
|
|
arr = []
|
|
l = 101
|
|
for i in range(0,l):
|
|
arr.append([])
|
|
for j in range(0,l):
|
|
arr[i].append('O')
|
|
|
|
start=int((l-1)/2)
|
|
|
|
X = start
|
|
Y = start
|
|
|
|
rX = start
|
|
rY = start
|
|
|
|
with open(input_f) as file:
|
|
for line in file:
|
|
tmp = list(line.rstrip())
|
|
arr[X][Y] = 'X'
|
|
arr[rX][rY] = 'X'
|
|
for idx,i in enumerate(tmp):
|
|
if idx % 2 == 0:
|
|
if i == '^':
|
|
Y -= 1
|
|
if i == '>':
|
|
X += 1
|
|
if i == '<':
|
|
X -= 1
|
|
if i == 'v':
|
|
Y += 1
|
|
else:
|
|
if i == '^':
|
|
rY -= 1
|
|
if i == '>':
|
|
rX += 1
|
|
if i == '<':
|
|
rX -= 1
|
|
if i == 'v':
|
|
rY += 1
|
|
|
|
arr[X][Y] = 'X'
|
|
arr[rX][rY] = 'X'
|
|
|
|
for idx,i in enumerate(arr):
|
|
for jdx,j in enumerate(i):
|
|
if arr[idx][jdx] == 'X':
|
|
result += 1
|
|
print(result)
|