Advent of Code 2022 Day 6 | Functional JavaScript

preview_player
Показать описание

Topics covered:
- recursive functions
- function parameters with default arguments
- using a Set data structure for counting unique elements
- nullish coalescing operator
- sliding window algorithms

Thanks for watching!
Рекомендации по теме
Комментарии
Автор

Well done and holy smokes you're bright and early today! :)

Billestlà
Автор

Well, that was easier than anticipated. It's interesting how some of these puzzles really lean into some simple features of the style someone uses.

I solved this with a Reduce that was probably over complicated. I tracked 3 properties in an object: a "buffer" that contained the last 4 characters, a counter so we could see where we were in the string, and the answer when we found it.
I got to that solution because I couldn't figure out how to return the answer from the middle of the reduce function (i.e. 7 iterations in).

Any tips on that one? Another really well explained video :)

robwatson
join shbcf.ru