renamed 2 digit file names

This commit is contained in:
Tristan 2018-12-10 23:56:11 +00:00
parent 018011dd27
commit b4d985a55a
44 changed files with 0 additions and 0 deletions

1
2015/03/input.txt Normal file

File diff suppressed because one or more lines are too long

18
2015/03/part1.py Normal file
View file

@ -0,0 +1,18 @@
with open("input.txt", "r") as commands:
x = 0
y = 0
history = []
for command in commands.readlines()[0]:
if command == ">":
x += 1
elif command == "<":
x -= 1
elif command == "^":
y += 1
elif command == "v":
y -= 1
if not [x, y] in history:
history.append([x, y])
print(len(history))
commands.close()

38
2015/03/part2.py Normal file
View file

@ -0,0 +1,38 @@
# lets just make it object oriented wtf
class Dud ():
def __init__ (self):
self.x = 0
self.y = 1
def do(self, command):
if command == ">":
self.x += 1
elif command == "<":
self.x -= 1
elif command == "^":
self.y += 1
elif command == "v":
self.y -= 1
with open("input.txt", "r") as commands:
santa = Dud()
robo = Dud()
history = set()
num = 0
for command in commands.readlines()[0]:
dud = santa if num % 2 == 0 else robo
dud.do(command)
history.add((dud.x, dud.y))
num += 1
print(len(history))
commands.close()