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
96
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
87
Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
90
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
150
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
51
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
43
An Introduction to Kotlin
tginsberg
0
73
Three New Features Coming to Java
tginsberg
0
47
An Introduction to Kotlin
tginsberg
0
37
Java Cram Session: Get caught up on the latest Java changes
tginsberg
0
30
Other Decks in Programming
See All in Programming
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
280
Generating OpenAPI schema from serializers throughout the Rails stack - Kyobashi.rb #5
envek
1
440
たのしいSocketのしくみ / Socket Under a Microscope
coe401_
8
1.4k
ナレッジイネイブリングにAIを活用してみる ゆるSRE勉強会 #9
nealle
0
170
未経験でSRE、はじめました! 組織を支える役割と軌跡
curekoshimizu
1
210
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
330
AIプログラミング雑キャッチアップ
yuheinakasaka
20
5.4k
バッチを作らなきゃとなったときに考えること
irof
2
560
.NET Frameworkでも汎用ホストが使いたい!
tomokusaba
0
210
コードを読んで理解するko build
bells17
1
120
フロントエンドオブザーバビリティ on Google Cloud
yunosukey
0
100
Boos Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
740
Featured
See All Featured
Fireside Chat
paigeccino
35
3.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
GraphQLとの向き合い方2022年版
quramy
44
14k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
How GitHub (no longer) Works
holman
314
140k
Side Projects
sachag
452
42k
Building Applications with DynamoDB
mza
93
6.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
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