Advent of Code with Kotlin [Day 1 to 7]

Kotlin to solve AdventOfCode

If you never heard about AdventOfCode, let me briefly introduce it to you:

Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.

How do I get there

AdventOfCode is a really interesting web page and I got there after completing the Kotlin Koans exercises. If you are interested in learn more about Kotlin, I really encourage you to do it! it’s really useful and fun.

After you finish all the Kotlin Koans, it invites you to do the Advent of Code, but it’s not really a condition to do it:

How does it works?

It’s simple, you go to the web page and you will find a Christmas Tree divided in 25 parts, each part represent a “day”:

Empty Christmas Tree

Every day has 2 puzzles to solve. Every time you solve a puzzle, it will give you a “star”, so in consequence, you will be able to get 2 stars per day, like this:

Two stars for day 1

You can start at any day. The first day of course is the easier one to solve, then the puzzles starts to get more complicated.

You can login with different social account so you can track your status:

Day 1 to 7

I started to solve each programming puzzle and I got until day 7 as every puzzle takes time to solve it so I just got here but my idea is to continue spending time to solve the other puzzles, but for sure I’m going to do it when I had time :)

Here you have the code for those 7 days:

I’m using Intellij IDEA to develop and run the code:


Here you have an example for day 1 in order to get two stars:


Please feel free to fork it and improve this code! I want to learn from you and for sure there are better ways to write this code in a more Kotlin-ized way. Don’t hesitate to ask any question, I’ll try to do my best to answer it.

Thanks and keep in contact!