Solving day 4 of Advent of Code 2022 in JavaScript

preview_player
Показать описание
I've made a couple of mistakes 🙊 did I manage to solve both parts??

Advent of Code is a website that releases a new programming puzzle every day between the 1st and the 25th of December.

0:00 Part 1
20:10 Part 2

Have fun!

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

Thank you so much for showing us your thought process and not just giving us a polished video - it was great seeing how you worked it out.

RichardSouth
Автор

Thanks for the video, I just had trouble with getting the data to a sorted array, but you helped me with that. For the answer in pt.1. if a range encompasses another range then its either fully surrounded or fully inside the range. I found it easier to just do a simple if statement.

Ex. values a, b and c, d. If one is fully encompassed in the other its either a c d b or c a b d
so I found it easier just to check whether arr1[0] <= arr2[0] && arr1[1] >= arr2[1] and then the opposite signs for the other condition. count up how many times its true. Sorry if that was confusing explanation.

travysto
Автор

Good job solving this one. Pretty hard challenge for a sunday. I am amazed at how fast you find the solution ! Struggled for some time to reformat the input tbh...
That's some nice sort function use.

Sachakonskier
Автор

There is a some and every array method

gixxerblade