Part 1 | Part 2 | Total | |
---|---|---|---|
Time | 17:58 | 44:36 | 1:02:34 |
It's been a blast! This is my first time ever completing all the puzzles of an Advent of Code year, and it feels great! I grinded on 12/24 before midnight to get all the puzzles I was behind on (due to exams and Christmas activities). Unfortunately, I was not able to complete Day 24 Part 2 in time, so my 50th star was locked out. After completing Day 25 Part 1, I decided to stay up and work on Day 24 Part 2 (which honestly was just waiting for my silly code to finish running 30 minutes later).
I was 2077th to complete Day 25 Part 2 and hence, 2077th to complete all of Advent of Code 2022! (That's 1=2=02th in SNAFU.)
It's been a wild ride, and a whole lot of fun;
Talking with elephants, monkeys, and elves.
We learned a lot and improved ourselves.
Goodnight, and Merry Christmas everyone!
from helpers.datagetter import data_in, submit
ans = 0
din = data_in(split=True, numbers=False)
def snafu(n):
num = 0
for i in range(len(n)):
place = len(line) - i - 1
if line[i].isdigit():
num += int(line[i]) * 5 ** place
elif line[i] == "-":
num -= 5 ** place
elif line[i] == "=":
num -= 5 ** place
num -= 5 ** place
return num
def unsnafu(n):
s = ""
while n:
m = str(n % 5)
if m == '3':
s = "=" + s
n //= 5
n += 1
elif m == '4':
s = "-" + s
n //= 5
n += 1
else:
s = m + s
n //= 5
return s
for line in din:
ans += snafu(line)
print(ans)
ans = unsnafu(ans)
print(ans)
submit(ans)
I just clicked the button...