Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Advent of Code in Kotlin: Lessons Learned
Todd Ginsberg
January 27, 2021
Programming
0
34
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
An Introduction to Kotlin
tginsberg
0
34
Three New Features Coming to Java
tginsberg
0
20
An Introduction to Kotlin
tginsberg
0
11
Java Cram Session: Get caught up on the latest Java changes
tginsberg
0
5
An Introduction to Kotlin
tginsberg
0
73
An Introduction to Kotlin
tginsberg
0
71
An Introduction to Kotlin
tginsberg
0
51
An Introduction to Kotlin
tginsberg
0
39
Write Less Code with Kotlin and Spring Boot
tginsberg
0
210
Other Decks in Programming
See All in Programming
Automating Gradle benchmarks at N26
ubiratansoares
PRO
1
140
테라폼으로 ECR 관리하기 (How to Manage ECR with Terraform)
posquit0
0
520
VIMRC 2022
achimnol
0
130
WindowsコンテナDojo: 第4回 Red Hat OpenShift Localを使ってみよう
oniak3ibm
PRO
0
180
アジャイルで始める データ分析基盤構築
nagano
1
870
Rに管理されてみる
kazutan
0
250
2022年のモダンCSS改
tonkotsuboy_com
24
16k
Windows コンテナ Dojo 第5回 OpenShift で学ぶ Kubernetes 入門
oniak3ibm
PRO
0
150
Amazon SageMakerでImagenを動かして猫画像生成してみた
hotoke_neko
0
110
ファーストペンギンを志すものに伝えたい - 1人目のアジャイル推進者がたどった成功と失敗
psj59129
0
100
FullStack eXchange, July 2022
brucel
0
200
Pythonで鉄道指向プログラミング
usabarashi
0
130
Featured
See All Featured
Debugging Ruby Performance
tmm1
65
10k
What the flash - Photography Introduction
edds
62
10k
Visualization
eitanlees
125
12k
Fantastic passwords and where to find them - at NoRuKo
philnash
27
1.6k
4 Signs Your Business is Dying
shpigford
169
20k
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
196
9.5k
The Brand Is Dead. Long Live the Brand.
mthomps
46
2.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
5 minutes of I Can Smell Your CMS
philhawksworth
196
18k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
980
Infographics Made Easy
chrislema
233
17k
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