Skip to content

Instantly share code, notes, and snippets.

View TimCastelijns's full-sized avatar

Tim Castelijns TimCastelijns

  • Coolblue
View GitHub Profile
visited = [(0, 0)]
with open('day3.txt', 'r') as f:
s = f.readline()
x, y = 0, 0
for direction in s:
if direction == '>':
x += 1
elif direction == '<':
x -= 1
grid = [[False for x in range(1000)] for y in range(1000)]
with open('day6.txt', 'r') as f:
for line in f.readlines():
instructions = line.split()
x1, y1 = (int(i) for i in instructions[-3].split(','))
x2, y2 = (int(i) for i in instructions[-1].split(','))
for x, row in enumerate(grid):
for y, col in enumerate(row):
if x1 <= x <= x2 and y1 <= y <= y2:
nice = 0
with open('day5.txt', 'r') as f:
for word in f.readlines():
# 2 overlapping.
for i in range(0, len(word), 1):
part = word[i:i+2]
if word.count(part) >= 2:
break
else:
continue