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
110
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
100
Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
120
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
190
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
66
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
49
An Introduction to Kotlin
tginsberg
0
83
Three New Features Coming to Java
tginsberg
0
56
An Introduction to Kotlin
tginsberg
0
48
Java Cram Session: Get caught up on the latest Java changes
tginsberg
0
43
Other Decks in Programming
See All in Programming
単体テストの始め方/作り方
toms74209200
0
350
OpenNext + Hono on Cloudflare でイマドキWeb開発スタックを実現する
rokuosan
0
110
當開發遇上包裝:AI 如何讓產品從想法變成商品
clonn
0
2.9k
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
0
480
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
120
REST API設計の実践 – ベストプラクティスとその落とし穴
kentaroutakeda
2
340
Spring gRPC で始める gRPC 入門 / Introduction to gRPC with Spring gRPC
mackey0225
2
420
イベントストーミングから始めるドメイン駆動設計
jgeem
3
730
JSAI2025 RecSysChallenge2024 優勝報告
unonao
1
420
Passkeys for Java Developers
ynojima
2
760
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfold' relates to 'iterate'"
philipschwarz
PRO
0
170
DevDay2025-OracleDatabase-kernel-addressing-history
oracle4engineer
PRO
7
1.7k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
15
900
Rails Girls Zürich Keynote
gr2m
94
13k
YesSQL, Process and Tooling at Scale
rocio
172
14k
A better future with KSS
kneath
239
17k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Faster Mobile Websites
deanohume
307
31k
Music & Morning Musume
bryan
47
6.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
770
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
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