2021 advent of code - day 01 solutions

preview_player
Показать описание
first day of solutions -- not too bad!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

As a nasty data science guy I could not refrain myself from converting the list to np.array, taking a lagged difference and just count where the difference was positive. Overkill but should be fast 😂

filippopisello
Автор

I just stumbled across this video and i did this problem by myself b4 seeing your solution. I used the zip function to loop over the elements and compared them incremented my counter like this:

counter = 0
for (i, k) in zip(l, l[1:]):
if k > i:
counter+=1
print(counter)

Anyways nice video m8! I am gonna look forward to the next advent of code!

shervintheprodigy
Автор

these are amazing, looking forward to learn. thank you!

muddasirkhan
Автор

Anyone else think this was a more challenging question for day 1 than previous years?

SpeedingFlare
Автор

I spent more time trying to convert the txtfile into integers. was kinda embarassing

ericng
Автор

ditto! I used `prev` in first solution. After writing the second solution using list comprehension and zip I realized the first one could be done in similar fashion.
```
count = sum(True for f, s in zip(numbers, numbers[1:]) if s - f > 0)
```

apdy
Автор

could you link the video about the space complexity of for loops and how itertools can make that const? thanks!! very interesting video and neat solution in pt2

thirtysixnanoseconds
Автор

Hi. Some bad code for you Anthony, good luck tommorow :) Numbers are readed input
P1 -> print(sum(map(lambda x: 1 if x[0] < x[1] else 0, zip(numbers, numbers[1:]))))
P2 -> print(sum(map(lambda x: 1 if x[0] < x[1] else 0, zip((y:=list(map(sum, zip(numbers, numbers[1:], numbers[2:])))), y[1:]))))

marsma