Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Advent of Code in Kotlin: Lessons Learned
Search
Todd Ginsberg
January 27, 2021
Programming
0
91
Advent of Code in Kotlin: Lessons Learned
An introduction to the Advent of Code and what I learned about solving puzzles in Kotlin.
Todd Ginsberg
January 27, 2021
Tweet
Share
More Decks by Todd Ginsberg
See All by Todd Ginsberg
Todd Ginsberg April 14, 2024 0 3 Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
76
Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
77
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
150
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
48
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
42
An Introduction to Kotlin
tginsberg
0
70
Three New Features Coming to Java
tginsberg
0
45
An Introduction to Kotlin
tginsberg
0
36
Java Cram Session: Get caught up on the latest Java changes
tginsberg
0
28
Other Decks in Programming
See All in Programming
ASP. NET CoreにおけるWebAPIの最新情報
tomokusaba
0
210
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
380
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
2.2k
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
3.2k
SRE、開発、QAが協業して挑んだリリースプロセス改革@SRE Kaigi 2025
nealle
1
3.3k
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
29
4.8k
ASP.NET Core の OpenAPIサポート
h455h1
0
160
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
7
1.5k
動作確認やテストで漏れがちな観点3選
starfish719
5
870
ErdMap: Thinking about a map for Rails applications
makicamel
1
1.1k
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
140
Scaling your build logic
antalmonori
1
150
Featured
See All Featured
A designer walks into a library…
pauljervisheath
205
24k
Rails Girls Zürich Keynote
gr2m
94
13k
Code Reviewing Like a Champion
maltzj
521
39k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Navigating Team Friction
lara
183
15k
Writing Fast Ruby
sferik
628
61k
It's Worth the Effort
3n
184
28k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
6
220
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
GitHub's CSS Performance
jonrohan
1030
460k
Transcript
None
None
Photo by Elena Mozhvilo on Unsplash Photo by Markus Spiske
on Unsplash
None
None
None
None
None
None
None
None
•
• •
• • •
None
2020 Unofficial Advent of Code Survey - Jeroen Heijmans
None
Daniel Lin (@ephemient) Solved every daily puzzle in four different
languages. ephemient.github.io/aoc2020/
Joris Portegies Zwart (@jorispz) Solves puzzles using Kotlin Multiplatform. github.com/jorispz/aoc-2020
Jakub Gwóźdź Solved every puzzle and provided a visualization. In
Kotlin! jakubgwozdz.github.io/advent-of- code-2020/
Courtesy of @FuriousProgramm @FuriousProgramm Also attempting to solve this puzzle.
Manually.
Since 2017, I have solved each puzzle each day, in
Kotlin and blogged about it. https://todd.ginsberg.com
None
•
val letters = listOf("A", "B", "C", "D") val numbers =
listOf(1, 2, 3, 4)
val letters = listOf("A", "B", "C", "D") val numbers =
listOf(1, 2, 3, 4) letters.zip(numbers) // [(A, 1), (B, 2), (C, 3), (D, 4)] // List<Pair<String,Int>>
val letters = listOf("A", "B", "C", "D")
val letters = listOf("A", "B", "C", "D") letters.zipWithNext() // [(A,
B), (B, C), (C, D)] // List<Pair<String,String>>
val letters = listOf("A", "B", "C", "D")
val letters = listOf("A", "B", "C", "D") letters.chunked(2) // [[A,
B], [C, D]] // List<List<String>>
val letters = listOf("A", "B", "C", "D", "E", "F")
val letters = listOf("A", "B", "C", "D", "E", "F") letters.windowed(3)
// [[A, B, C], [B, C, D], [C, D, E], [D, E, F]] // List<List<String>>
val letters = listOf("A", "B", "C", "D", "E", "F") letters.windowed(3,
3) // [[A, B, C], [D, E, F]]
val letters = listOf("A", "B", "C", "D", "E", "F") letters.windowed(4,
4, false) // [[A, B, C, D]]
val theString = "Hello" theString.padEnd(7, '!') // Hello!!
val theString = "Hello" theString.padStart(7, '!') // !!Hello
val theString = "Left Right"
val theString = "Left Right" theString.substringBefore(" ") // "Left"
val theString = "Left Right" theString.substringBefore(" ") // "Left" theString.substringAfter("
") // "Right"
val someList = listOf("A", "B", "C")
val someList = listOf("A", "B", "C") someList.any { it.length ==
1 } // True!
val someList = listOf("A", "B", "C") someList.all { it.length ==
1 } // True!
val someList = listOf("A", "B", "C") someList.none { it.length ==
2 } // True!
"3".toInt() // 3
"3".toInt() // 3 '3'.toInt() // 51
fun Char.asInt(): Int = this.toString().toInt()
fun Char.asInt(): Int = this.toString().toInt() '3'.asInt() // 3
• •
• • •
• • • •
• • • • •
None
None
None
None
None
None
None