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
82
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
48
Loom is More Than Virtual Threads: Structured Concurrency and Scoped Values
tginsberg
0
42
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
120
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
30
Beyond JUnit: Pragmatic Ways to Increase Code Quality
tginsberg
0
41
An Introduction to Kotlin
tginsberg
0
58
Three New Features Coming to Java
tginsberg
0
32
An Introduction to Kotlin
tginsberg
0
24
Java Cram Session: Get caught up on the latest Java changes
tginsberg
0
18
Other Decks in Programming
See All in Programming
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
340
Architecture Decision Record (ADR)
nearme_tech
PRO
1
670
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
260
事業フェーズの変化に対応する 開発生産性向上のゼロイチ
masaygggg
0
180
Mastering AsyncSequence - 使う・作る・他のデザインパターン(クロージャ、Delegate など)から移行する
treastrain
4
1.6k
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
740
Our Websites Need a Lifestyle Change, Not a Diet
ryantownsend
0
140
マルチモジュールにおけるテスト最適化
fxwx23
0
200
connect-go で面倒くささと戦う / 2024-08-27 #newmo_layerx_go
izumin5210
2
630
GraphQLの魅力を引き出すAndroidクライアント実装
morux2
3
320
Regular Expressions, REXML, Automata Learning
makenowjust
0
210
dRuby 入門者によるあなたの身近にあるdRuby 入門
makicamel
4
350
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
Designing for humans not robots
tammielis
248
25k
The Invisible Customer
myddelton
119
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
502
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
8.9k
The Brand Is Dead. Long Live the Brand.
mthomps
53
37k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
4 Signs Your Business is Dying
shpigford
179
21k
Embracing the Ebb and Flow
colly
83
4.4k
Visualization
eitanlees
142
15k
Designing Experiences People Love
moore
138
23k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
130k
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