Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the problems in several languages.

Solutions by Coder

Solutions by Day

Day Language Coder

day01

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

python

Ralf D. Müller

javascript

{olithissen}

kotlin

Michi Gysel

typescript

Waldemar Schäfer

elm

{RobertWalter83}

python

{sancho1241}

day02

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

swift

{hcsama}

python

Ralf D. Müller

javascript

{olithissen}

kotlin

Michi Gysel

typescript

Waldemar Schäfer

elm

{RobertWalter83}

day03

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

python

Ralf D. Müller

javascript

{olithissen}

kotlin

Michi Gysel

elm

{RobertWalter83}

python

{subesokun}

day04

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

python

Ralf D. Müller

javascript

{olithissen}

kotlin

Michi Gysel

elm

{RobertWalter83}

python

{subesokun}

day05

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

python

Ralf D. Müller

javascript

{olithissen}

kotlin

Michi Gysel

elm

{RobertWalter83}

python

{subesokun}

day06

javascript

Tobias Schulte

javascript

Andreas Offenhaeuser

go

Andreas Offenhaeuser

java

{highsource}

python

Ralf D. Müller

javascript

{olithissen}

typescript

Waldemar Schäfer

elm

{RobertWalter83}

python

{subesokun}

day07

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

javascript

{olithissen}

elm

{RobertWalter83}

python

{subesokun}

day08

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

swift

{hcsama}

groovy

Ralf D. Müller

javascript

{olithissen}

elm

{RobertWalter83}

python

{subesokun}

day09

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

elm

{RobertWalter83}

day10

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

groovy

Ralf D. Müller

javascript

{olithissen}

typescript

Waldemar Schäfer

elm

{RobertWalter83}

go

{subesokun}

python

{subesokun}

day11

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

swift

{hcsama}

groovy

Ralf D. Müller

python

{subesokun}

day12

javascript

Tobias Schulte

go

Andreas Offenhaeuser

java

{highsource}

day13

go

Andreas Offenhaeuser

java

{highsource}

groovy

Ralf D. Müller

day14

go

Andreas Offenhaeuser

java

{highsource}

day15

go

Andreas Offenhaeuser

day16

go

Andreas Offenhaeuser

java

{highsource}

day17

go

Andreas Offenhaeuser

java

{highsource}

day18

go

Andreas Offenhaeuser

java

{highsource}

groovy

Ralf D. Müller

day19

go

Andreas Offenhaeuser

java

{highsource}

day20

go

Andreas Offenhaeuser

java

{highsource}

day21

go

Andreas Offenhaeuser

java

{highsource}

day22

java

{highsource}

day23

go

Andreas Offenhaeuser

java

{highsource}

day24

go

Andreas Offenhaeuser

java

{highsource}

day25

java

{highsource}

Today I learned..

A collection of everyones daily learnings

Day 1

7142618?s=40

  • .. that Go only has for loops

1856308?s=40

  • Elm is a language which seems to compile / transpile to JavaScript

5462981?s=40

  • I learned how to use List.foldl/foldr in elm

1065960?s=40

  • How to create an infinite, repeating Sequence in Kotlin.

  • There is no map operator that also provides an accumulator in Kotlin (such as ReactiveX Scan)

203910?s=40

  • How to read a file in JavaScript and split by line ending

  • That JavaScript may implicitly convert a string to a number (e.g. that 1 + "1" == "11" but 1 * "1" === 1)

  • How to explicitly convert a string to a number using Number("1")

  • That Number("") and Number(null) both are 0

  • That NaN !== NaN, but you have to use isNaN(NaN) instead

Day 2

7142618?s=40

  • .. all my go projects need to go into ~/go/src, which solves the dependency link problem for go

1856308?s=40

  • Documentation driven development: first write the docs, then do the coding. Works great on top of test driven development!

  • Python has no power-assertions like groovy has. Makes testing harder 😒

  • VS Code and thus gitlab has a column mode for editing!

  • All your tests might run fine but the solution is still wrong

5462981?s=40

  • that it is hard to drop the imperative mindset if you are used to it too much

1065960?s=40

  • The zip operator in Kotlin combines two Lists into a List<Pair>>

  • It makes sense to return either List or Sequence from your functions depending on the result size (List or Stream in Java)

Day 3

1856308?s=40

  • how classes work in Python

  • Asciidoctor lets you exclude tags in the include statement

7142618?s=40

  • .. structs and maps are super powerful 🤯

  • ..go is fast 💨

13063051?s=40

  • Get the test input working first and assert that the results match the example

5462981?s=40

  • that parsing the input data is sometimes the most challenging part of these early tasks

Day 4

7142618?s=40

  • being able to increment a non-existant integer value without checking for its existence first is super convenient

  • splitting strings is easier than regexing

1856308?s=40

  • how to create your own python modules

1065960?s=40

  • you can destructure in Kotlin from an Array, a List, or e Map.Entry (and probably more…​)

  • Kotlin’s Iterable<T>.groupingBy offers a nice way to group and then aggregate.

  • How to use fold with a stateful accumulator

13063051?s=40

  • Sometimes you spend so much time on a solution that you are afraid to start over again

  • I started measuring function execution performance

  • Once you solved a task, add asserts for your correct answers so you don’t mess up during optimization

5462981?s=40

  • that the elm compiler is awesome

  • how to effectivley use elm’s REPL

Day 5

7142618?s=40

  • if you struggle with a problem, take a break, clear your head and get a new perspective

  • never assume any part of your code is too simple to have an error

  • pipes do not only split on new lines - also if chunks are too large

13063051?s=40

  • Wake up, read the task, get a rough plan while falling asleep again

  • Javascripts Array.splice() is blazingly fast and works in-place

  • Loops are costly. Knowing what you are doing can make your code faster (In this case: From 3,960 msec to 360 msec)

  • Get feedback! Hints from 7142618?s=40 and 1856308?s=40 helped cut another 60 msec

Day 6

7142618?s=40

  • unit tests in Go feel really verbose to write (no assertions only failure checking)

  • writing modular/cleaner code seems to result in more loops than necessary

  • (again) structs and maps are profit!

Day 7

7142618?s=40

  • graphs are fun but are super headache if you don’t have 📝 (or experience)

  • finally figured out that the regexp function I always need (get matches): FindStringSubmatch

  • you can implement a simple queue in Go using a slice and

    • el := q[0]; q = q[1:] to pop an element from top

    • el := q[i]; q = append(q[:i], q[i+1:]…​) to remove an element in the middle

  • Go has a …​ spread operator

203910?s=40

  • how to define classes in JavaScript

Day 8

5462981?s=40

  • That, even after all these years, recursion can still cause a knot in my brain

  • immutable data can sometimes be a burden

Day 9

5462981?s=40

  • That it is vital to have an intuitive understanding of how the core data structures behave within a language to use them successfully

  • you can basically do anything with lists and dictionaries

203910?s=40

  • 20 years ago I learned that array modifications are slooow. Somehow I must have forgotten. Now I know again.

  • The JavaScript spread operator

Day 11

7142618?s=40

  • Go unit tests need to start with func Test<Name> whereas Name needs to be capitalized, otherwise NOTHING happens 😡 rtfm

1856308?s=40

  • there is no asciidoctor plugin for xcode!

  • today’s solution part 2 is too slow to finish, but the solution already showed up after a few iterations 😎

Day 12

7142618?s=40

  • I still seem to lack knowledge of how pointers and linked lists work; spent 3 hours implementing my own type with a bi-linked list but in practice it threw a lot of weird pointer exceptions

Day 13

1856308?s=40

  • if you want to animate your output on the console print "\u001b[2J" clears the screen and print "\u001b[H" moves the curser to the upper left corner

Day 15

7142618?s=40

  • if I had not rebased my codebase I could see how many hours I wasted on this 🙃

Day 16

7142618?s=40

  • The correct syntax to assign functions to a variable is var := func (input string) bool {} (anonymous function)

Day 17

7142618?s=40

  • You can use fmt.Scanln() to pause your program until a newline is entered. This is amazing in combination with 1856308?s=40 finding of Day 13 how to reset a screen to do animations.