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

preview_player
Показать описание
We continue to learn Kotlin with the Kotlin team.

Grouping and counting the characters in strings and collections is a very typical task given in coding interviews. Usually, the solutions for such tasks are quite simple. In this video, we learn about a few useful functions in Kotlin that make set operations really simple.

Day 6: Custom customs
Learn how to group and count characters in strings and collections using the standard library functions: 'map', 'reduce', 'sumOf', 'intersect', and 'union'.

0:00 Introduction
0:48 Task description
1:30 Reading the input
2:00 Naive solution
3:00 Use sumOf function
3:22 Part 2 of the challenge
4:00 Naive solution to the 2nd part
6:01 Using reduce function
6:30 Refactoring the solution
8:47 Common solution to both parts
9:30 Outro

* Used with the permission of Advent of Code (Eric Wastl)
#Kotlin #Idiomatic #Tutorial #AdventOfCode #AdventOfCode2020 #AdventOfСodeInKotlin #Day6
Рекомендации по теме
Комментарии
Автор

Антон, ты конечно супер крут. Знание горячих клавиш + Kotlin это мощно!

avdim
Автор

Thank you. I've never used intersect or Union functions before.

ArthurEmbleton
Автор

Очень круто прокачивать навыки программирования на православном Котлине по таким видео. Спасибо!!!

bdiuhgu
Автор

Love this choice of talk - Sets are often strangely overlooked!
One of my secret hobbies is converting usages of List to Set, where that better fits the character of the data.

DarkmoonUK
Автор

Hello
Nice content so far, but I would like to offer a constructive comment for the betterment of this series.

Can you please take more time explaining the problem so that the viewer may be able to know what we are trying to accomplish, instead of partially explaining the sections in the problems and hacking away.

Otherwise, this is a good series

andy_lamax
Автор

*UNPOPULAR OPINION:* Idiomatic collection processing is less readable than expanded for/if-else constructs.

jvm-tv
Автор

obviously it can be inline
\/
\/
\/
groups.sumOf { { a, b -> a intersect b }.size }

РоманГалушка-же