first commit

This commit is contained in:
fzorb 2025-05-01 12:38:17 +03:00
commit 31bda4481f
37 changed files with 4645 additions and 0 deletions

1
2015/three/example Normal file
View file

@ -0,0 +1 @@
^v^v^v^v^v

1
2015/three/input Normal file

File diff suppressed because one or more lines are too long

33
2015/three/solution-2.py Normal file
View 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)))

17
2015/three/solution.py Normal file
View file

@ -0,0 +1,17 @@
with open("./input", "r") as f:
instructions = list(f.read())
cursor = [0,0]
houses = []
for instruction in instructions:
if instruction == "^":
cursor[0] += 1
if instruction == "v":
cursor[0] -= 1
if instruction == ">":
cursor[1] += 1
if instruction == "<":
cursor[1] -= 1
houses.append(f"{cursor[0]},{cursor[1]};")
print(houses)
print(len(set(houses)))