Advent of Code is an annual event that's been running for around 10 years that gives out Christmas-related puzzles. I'd heard of it before, but never had the time nor desire to enter the challenge, mostly because December was a nightmare of a month everywhere I worked at before. This year, I had a change of heart.
While coding up a solution, I started writing code that I used to write when I was in my undergrad studies: when I wrote code to solve a problem, and only that. I didn't care about code quality, nor did I care about anyone that would maintain the code in the future. I didn't care about teammates, their tech stacks and knowledge levels, and I didn't care about how I'd explain to a client or an employer why I took so long on something. For the first time in ages, I coded for myself, and only myself. It wasn't for pay, publicity, tech interview prep or any real gain. It was coding for fun, and that stirred a feeling that I hadn't felt in a long while.
After coding professionally the last few years, working for a vision that was either forced on me or I intentionally took up to pay the bills, I almost forgot that I enjoyed coding.
The habits I'd picked up when I used to love it stuck with me and helped me immensely on my journey, but for some time now, I haven't gotten true enjoyment when writing code. I was chasing the high of snuffing out bugs and completing features, but the process was in the background: kind of like how when you're driving, you can space out, but you've somehow reached your destination without running over someone or running a red light. It was like that.
When all you do is code, at some point, you forget that you do this not because you're good at it, but because you used to enjoy it to some degree.
And I feel that it's important to never forget that.
Speaking of, that thought process brought up a song I used to listen to religiously back in high school:
So many times, it happens too fast
You trade your passion for glory
Don't lose your grip on the dreams of the past
You must fight just to keep them alive
- “Eye of the Tiger” by Survivor
For reference, this is the kind of code I wrote to pass the test:
with open('day1.txt', 'r') as file:
current_dial = 50
match_count = 0
for line in file:
direction = line[0]
distance = int(line[1:])
print("Found direction: ", direction, " and distance: ", distance)
if direction == 'R':
for i in range(distance):
current_dial += 1
if current_dial > 99:
current_dial = current_dial - 100
if current_dial == 0:
match_count += 1
pass
else:
for i in range(distance):
current_dial -= 1
if current_dial < 0:
current_dial = 100 + current_dial
if current_dial == 0:
match_count += 1
pass
print("Match count: ", match_count)
passMessy, solves the problem but it's not optimized, nor is it particularly clean. Just code that does something, a throwaway script, if you will.