I love these little challenges because it keeps me sharp, makes me think about things differently than I may be doing daily at work. Also, who doesn’t love to code?
If you’re starting out, or fairly new to coding, or an old guy like me, I challenge you to give this a try, every day, until Christmas.
It was a blast! Thank you Eric Wastl and team for creating this really fun month! Below I share my thoughts and findings from this great experience.
What is Advent?
Christians look to Advent as the season of waiting for the birth of Jesus Christ. During the 4 weeks before Christmas, we reflect and celebrate His birth. The word advent literally means “coming”, thus the coming of Christ.
“Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.” ref Who doesn’t love an advent calendar? If you’re not a Christian, that’s okay too, I don’t think AoC has any religious ties.
You’ll also notice each day I used an advent photo, something pointing to the birth of Christ. Advent is the count down to the best day of the year, the celebration of His birth and bringing us salvation.
Here are the photos I used throughout with credits:
My top 5 favorite coding challenges
I enjoyed many of the challenges. Some were, well, boring, but not many. Some also were refreshingly simple after a day or two of harder ones. You can see all my solutions using Git pages or directly in the repo, and of course there’s a blog post for each. Here are my top 5 favorite challenges, in no particular order:
Day 17 was haaaaard and so rewarding when I was done. We dabbled in 3 dimensional space, and then the 4th dimension. This was one that required a lot of sketching to understand where the code was going. It was a lot of fun
Day 10 was the first real problem puzzle I hit. The scripts I had running estimated 629 days to complete. 2 years… Obviously that wouldn’t work. I ran into a couple of other puzzles that were heading in this same direction. After some googling and reading through others’ solutions on the AoC subreddit, I discovered why this was so slow, and how to fix it. A great lesson learned.
Day 5 introduced our first challenge working with locations: trying to find my seat on an airplane. This one was fun and new for me. I don’t do much location-based programming. A few more days had similar challenges in them.
Day 12 was difficult and required some strong imagery to wrap my head around the boat in the sea. It was really fun to be steering a boat around.
Day 22 reminded me a lot of playing cards with my kids. I thoroughly enjoyed writing this one because I’ve thought through this so many times while playing War.
My top 5 lessons learned
Black Lives Matter
Today’s puzzle [day 24] uses two color options, black and white. And as we step through the rules we are changing tiles from black to white, and visa-versa. At some point I need to find how many black neighbors a tile has and change it based on that count. This felt all too real, and insensitive. I did not want to work with these color choices and terms. Instead, I completed it by using green and red instead. It’s Christmas time! Let’s stick with Christmas colors ;)
Black Lives Matter every day, not just when our news media says it does.
I think it’s important to be inclusive and aware even in our code. Heck, GitHub changed default branches from
main for the same reason.
Regular Expressions continue to be so powerful. I’ve always been a fan of it and I promote it when I can. You don’t need regex to complete the tasks, you can loop and parse to find what you need. Regex just does it so much faster. I highly suggesting deferring to regex whenever you can. Check out regex101.com for a GREAT tool to learn and parse your data.
Mental models are important, and don’t shy away from making them tangible. I can usually picture a solution in my head, I can picture the boat in the sea spinning or where my seat is on a plane. However, I found making these tangible, drawing them out on paper or digitally, helps really clarify what we’re trying to do. Towards the end, I was sketching almost every puzzle. I wish I had a whiteboard at home…
The importance of ETL. Extract, Transform and Load is important in SO many of these challenges. I have, in the past, tried to bury ETL in one fell swoop, in minimal lines, or act like it’s not needed and deal with data in the logic itself. Silly me. Over the last few years, and especially in these puzzles, I realize how important it really is. Prep your data before you work with it. It makes code much simpler and cleaner.
Clean code over less code. I certainly had a lot of code in some challenges, like the waypoint rotation in day 12 part 2. The code looks redundant, with 1 minor variable or value difference. I could refactor that and remove many many lines of code, but is that best? I don’t play code golf. Instead, I want to write code that is clean and understandable, especially when I know I’ll be sharing it with others through my blog (or teammates at work, or myself 2 months from now). I also realized after completing days I could refactor a lot of my code to reduce the size AND make it clean and understandable. But who has time for that :D
To those doing it better than me
THANK YOU! I shared my colleague’s repos early on, and there is a great subreddit dedicated to AoC, but I wanted to give a shout out to some specific people who I referenced code from to complete my days:
- Thank you Connor, for your help on Day 10 and your creation of the Slack Leaderboard
- Thank you Josh, for your code examples on Days 13 and 14
- Thank you Eremiten Annsofi (@annsofip), for commenting and introducing me to Map() in Day 15, greatly improving my performance
- Thank you eQueline, for your code for Day 19
- Thank you lnguyenh, for your code for Day 23 and introducing me to the idea of a link list
Collaboration is awesome, and I found AoC truly highlighted this. Not only was I able to learn from others, I was able to help others as well.
The Leaderboard and Stats from AoC
I shared and promoted people joining my leaderboard, and as a result, I didn’t end in the top 3 ;) But that’s okay! It was fun collaborating and hearing from some of you who joined my board. I did place 5th, not too shabby.
Here’s the current standings:
Oh yea, there’s a way to include your leaderboard in Slack too ;)
Here’s some real interesting data on the AoC overall:
I’m pleased to share I’m one of the 10933 that finished! I’m sure that number will grow as people complete the year.
This is my own stats for each day. The Time isn’t the duration, but the time I marked it completed, I think. The
>24h I believe indicates those I completed after the day.
One thing I did pick up that I missed was the determination to get something done. Outside of work, since COVID started, my motivation has been less than before. I’ve started things and let them linger on. Having the daily deadline and fear of falling behind, I coded as much as I could to keep up. This was a refreshing feeling and one I look forward to continuing in 2021.
A few days I mentioned I just didn’t have time to work it so I’d use someone else’s code. I’m not a fan of that, but with a full time job, 4 kids, 2 dogs, side projects, The Mandalorian, and all during a pandemic, time isn’t on my side.
From here, I think I will explore doing 100 days of code. I’ve also starting connecting with colleagues on my team to do something similar within our team. I will also look at the previous years of AoC and see if I can get some more stars.
Will I do AoC in 2021? I think so, but won’t commit, who knows what 2021 will hold!
What about you?
Did you follow along? How was AoC for you? What did you get out of it? Many have shared their thoughts on the AoC subreddit. Feel free to share your thoughts here too, I’d love to hear from you!