aoc-2021-rust

Advent of Code 2021 Solutions in Rust
git clone https://git.sinitax.com/sinitax/aoc-2021-rust
Log | Files | Refs | README | sfeed.txt

part2 (1550B)


      1--- Part Two ---
      2
      3Considering every single measurement isn't as useful as you expected: there's just too much noise in
      4the data.
      5
      6Instead, consider sums of a three-measurement sliding window.  Again considering the
      7above example:
      8
      9199  A      
     10200  A B    
     11208  A B C  
     12210    B C D
     13200  E   C D
     14207  E F   D
     15240  E F G  
     16269    F G H
     17260      G H
     18263        H
     19
     20Start by comparing the first and second three-measurement windows. The measurements in the first
     21window are marked A (199, 200, 208); their sum is 199 + 200 + 208 = 607. The second window is marked
     22B (200, 208, 210); its sum is 618. The sum of measurements in the second window is larger than the
     23sum of the first, so this first comparison increased.
     24
     25Your goal now is to count the number of times the sum of measurements in this sliding
     26window increases from the previous sum. So, compare A with B, then compare B with C, then C with
     27D, and so on. Stop when there aren't enough measurements left to create a new three-measurement sum.
     28
     29In the above example, the sum of each three-measurement window is as follows:
     30
     31A: 607 (N/A - no previous sum)
     32B: 618 (increased)
     33C: 618 (no change)
     34D: 617 (decreased)
     35E: 647 (increased)
     36F: 716 (increased)
     37G: 769 (increased)
     38H: 792 (increased)
     39
     40In this example, there are 5 sums that are larger than the previous sum.
     41
     42Consider sums of a three-measurement sliding window. How many sums are larger than the
     43previous sum?
     44
     45