Advent of Code 2015 in Kotlin, done at a slow pace in 2022
This is done together with a few friends and colleagues who want to use the AoC problems to improve their coding proficiency. In my case, I am using these problems to practice Kotlin while I learn it.
A remark on Kotlin for each “day”:
- 01:
when()
control structure (or expression) is nice to have – also appeared in python 3.10 - 02: extensions functions combine well with a “functional programming” style
- 03: companion object is Kotlin’s way of grouping “constant” or “static” members of a class
- 04: single-line
fun
definitions with=
and expressionif
may help with short, readable code - 05: maybe extension functions should be scope-restricted to avoid accidental misuse?
- 06: during class inheritance, explicit use of the
override
keyword is mandatory - 07: testing for
null
can be chained with “elvis operators” - 08: beware of
Regex
expressions containing backslashes or double quotes, even in “raw” strings - 09: nullability checks matter, notably for map elements! (and can cause headaches when absent…)