AdventOfCode/2015/day3/part1.py

42 lines
737 B
Python
Raw Normal View History

2023-12-04 18:03:20 +01:00
#!/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
with open(input_f) as file:
for line in file:
tmp = list(line.rstrip())
arr[X][Y] = 'X'
for idx,i in enumerate(tmp):
if i == '^':
Y -= 1
if i == '>':
X += 1
if i == '<':
X -= 1
if i == 'v':
Y += 1
arr[X][Y] = 'X'
for idx,i in enumerate(arr):
for jdx,j in enumerate(i):
if arr[idx][jdx] == 'X':
result += 1
print(result)