Advent of Code 2020 Day 1 | Functional JavaScript

preview_player
Показать описание
Using a two pointers strategy, we solve part 1 with a time complexity of O(n * log(n)) and part 2 with a time complexity of O(n ** 2).

Where can I find the code?

What's advent of code?
❤ it's an exciting annual event that offers fresh coding challenges for each day of December up to the 25th

What's functional JavaScript?
❤ JavaScript is a popular programming language, originally used for making websites
❤ functional programming is a paradigm in which everything is a function, values are never re-assigned, and functions have no side effects
❤ functional JavaScript isn't a special language; it's just JavaScript code that's been written to follow the functional programming paradigm

Questions, comments, concerns?
❤ comment below :)

Remember to believe in yourself
anything is possible
Рекомендации по теме
Комментарии
Автор

very cool video!
I'm relatively new to Javascript and going deep on intermediate to advanced language use/programming concepts and applications. Doing various leetcode challenges as well some Advent of Code's. Currently on 2015 day 3 o/.

Your explanation is very good and precise and I really liked your 3 steps on writing your logic/code. I always try to do exactly that.

This simple yet very clear and on-point use of recursive functions and nested ternaries REALLY opened my eyes to a lot of possibilities!

Thanks! :)

veremox
Автор

This is such a brilliant video, thanks for walking through these exercises!
It's so helpful! Subscribed and will definitely by watching more.

Jayman
Автор

The sorted array approach is really nice, thanks for that 👍. I would argue that console.log is indeed a side effect, but since it does not change the way how the code works that's totally fine. However, if we need to be aware of multiple values programmatically an object might be a good return value. I'm looking forward to your next days solutions. Actually i'm having a hard time understanding the assignment at day 3, part 2 🤔

jstask
Автор

Thank you for putting this together. This was very informative and I liked how you showed the different methods and their relative time complexity as you went along.

I have a question. When you converted the code into a functional program that is recursive, the big O complexity stayed the same I think (nlogn due to the sort algorithm). What were the benefits to changing the program to be recursive? Was it just to simplify the code or were there any additional benefits?

tornben
welcome to shbcf.ru