Day 1. Sonar sweep¶
Part one¶
Submarine has sonar and can measure depths. Each of the measurements is present as positive integer on a new line.
This part is really simple and requires us to calculate how many measuremnts are larger than previous measurement.
Here we iter over pairs of elements and compare the values.
1 2 3 4 5 6 7 8 9 10 |
|
Part two¶
This part is a bit trickier. Our goal now is to count the number of times the sum of measurements in this sliding window increases from the previous sum.
We iterate over windows of size 3 (iteration is kickstarted manually to get first triplet) and compare the sum of the current window with the sum of the previous window.
1 2 3 4 5 6 7 8 9 10 11 12 |
|