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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Todd Ginsberg
January 27, 2021
Programming
0
120
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
Stream Gatherers: The Missing Link in Java Streams
tginsberg
0
20
Loom is more than virtual threads: Structured Concurrency and Scoped Values
tginsberg
0
11
Stream Gatherers: The Missing Link in Java Streams
tginsberg
0
24
Todd Ginsberg April 14, 2024 0 3 Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
130
Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
160
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
220
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
84
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
57
An Introduction to Kotlin
tginsberg
0
110
Other Decks in Programming
See All in Programming
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
120
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
190
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
180
株式会社 Sun terras カンパニーデック
sunterras
0
2k
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
450
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
670
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
140
文字コードの話
qnighy
43
17k
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
110
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
8
2.4k
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
150
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
950
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
170
BBQ
matthewcrist
89
10k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
450
How to Ace a Technical Interview
jacobian
281
24k
The browser strikes back
jonoalderson
0
750
KATA
mclloyd
PRO
35
15k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Amusing Abliteration
ianozsvald
0
120
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
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