Learn Kotlin with the Kotlin Team: Advent of Code 2020 #9

preview_player
Показать описание
In this episode of the Learn Kotlin with the Kotlin team series, we’ll look at different ways to manipulate lists in Kotlin to solve the puzzle.

Day 9: Encoding error
Explore different ways to manipulate lists in Kotlin using the ‘any’, ‘firstOrNull’, ‘firstNotNullOfOrNull’, ‘windowed’, ‘takeIf’, and ‘scan’ functions, which exemplify an idiomatic Kotlin style.

0:00 Intro
0:36 Puzzle Description
1:57 Solution, Part I
4:25 Finding invalid number
6:32 Using ‘windowed’
9:08 Part II
9:52 Solution, Part II

* Used with the permission of Advent of Code (Eric Wastl)

#Kotlin #Idiomatic #Tutorial #AdventOfCode #AdventOfCode2020 #AdventOfСodeInKotlin #Day9
Рекомендации по теме
Комментарии
Автор

windowed() is a really neat function. I've found it particularly useful in algorithms that deal with a "current" and a "previous" element in the list. It is much clearer and less error prone than fiddling with the indices manually and carefully working around all corner cases.

AlanDarkworld
Автор

There are some functions in this video that I need to check out.

HtopSkills
Автор

Nice and neat solution, especially the improvement method of the second task, reminds of "integral image" from the viola jones face detection algorithm

cisimon
Автор

perhaps we could immediately break the inner loop, when the 'subListSum' is greater than the 'targetSum', to avoid unnecessary calculations for the rest 'toIndex'es, right?

Marth
Автор

🙏🏻Kotlin multiplateform mobile Beginners tutorial upload

pradyumnx
Автор

🙏🏻Kotlin multiplateform mobile Beginners tutorial upload

pradyumnx
Автор

🙏🏻Kotlin multiplateform mobile Beginners tutorial upload

pradyumnx
Автор

🙏🏻Kotlin multiplateform mobile Beginners tutorial upload

pradyumnx