first commit
This commit is contained in:
commit
31bda4481f
37 changed files with 4645 additions and 0 deletions
33
2015/three/solution-2.py
Normal file
33
2015/three/solution-2.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
with open("./input", "r") as f:
|
||||
instructions = list(f.read())
|
||||
cursor1 = [0,0]
|
||||
cursor2 = [0,0]
|
||||
houses = []
|
||||
turn = 0
|
||||
# turn 0 is santa, turn 1 is robosanta
|
||||
for instruction in instructions:
|
||||
if turn == 0:
|
||||
if instruction == "^":
|
||||
cursor1[0] += 1
|
||||
if instruction == "v":
|
||||
cursor1[0] -= 1
|
||||
if instruction == ">":
|
||||
cursor1[1] += 1
|
||||
if instruction == "<":
|
||||
cursor1[1] -= 1
|
||||
houses.append(f"{cursor1[0]},{cursor1[1]};")
|
||||
print("(*)" + str(cursor1))
|
||||
turn = 1
|
||||
else:
|
||||
if instruction == "^":
|
||||
cursor2[0] += 1
|
||||
if instruction == "v":
|
||||
cursor2[0] -= 1
|
||||
if instruction == ">":
|
||||
cursor2[1] += 1
|
||||
if instruction == "<":
|
||||
cursor2[1] -= 1
|
||||
print("(-) " + str(cursor2))
|
||||
houses.append(f"{cursor2[0]},{cursor2[1]};")
|
||||
turn = 0
|
||||
print(len(set(houses)))
|
Loading…
Add table
Add a link
Reference in a new issue