Advent of Code, day 12: Shooting for the moon
I won’t lie. I’m usually not the most competitive person out there. But when December nears, I’m getting a bit restless. And when I run into fellow players from previous year, the conversation quickly turns to the coming season of Advent of Code. “Will you be joining again this year?”, “Have you started preparing yet?”, “Which language will you use?” or “Going for the top position again this year?” are just some of the questions asked.
2016 was the first year I participated real-time. Even though I only started on day 6, I made it to a respectable 2nd place on our private leaderboard. I have to admit, the competition wasn’t as fierce back then. So just by completing all challenges, you would already end up near the top.
Then came the 2017 edition. There was some more buzz around it in the office. More players signed up for the private leaderboard, and I even set an alarm clock for 5:55 to make sure I got maximum chances for a good score (and I’m not the only one). And it worked! I got first place! True, it might have helped I was on parental leave, and probably had a bit more time to spare than my competitors. But a win is a win, and I even managed to score points for the global leaderboard. That felt good! Maybe there is a competitive side of me.
In 2018, the competition was even more fierce. More people were getting up before 6:00, and the internal Slack channel was more active than ever. People were comparing solutions and execution times, and overall having lots of fun. After day 24, there was a three-way tie for the top position. Bulat, Marcus and myself all had 1852 points. So it came down to the final day. Bulat ended up being the fastest to solve day 25, and although I ended on second place, we had a blast!
Ranking the stars
But being competitive, also means you’re curious to see how you are doing compared to your peers. The leaderboard however, only gives you the ranking based on the total score on the private leaderboard, global leaderboard or total number of stars acquired. That doesn’t really give you an insight into how you are doing over time…
To the moon and back
Today’s challenge was about tracking the moons of Jupiter. The first part was pretty straightforward, just tracking 4 objects over a limited amount of iterations. Earlier this week I said to a colleague, “Just wait until he [Eric Wastl] makes you do a trillion iterations”. Boy was I wrong. And not by an off-by-one, but almost by a factor 400!
$ time pypy3 part2.py Steps: 3.9E+14 pypy3 part2.py 0.28s user 0.03s system 94% cpu 0.323 total
Luckily python isn’t as slow as some would lead you to believe. 390 trillion steps in just 0.323s seconds. It got me first place today 🙂
Look at our consultancy services, training offers and careers below or contact us at firstname.lastname@example.org