part1 (2408B)
1--- Day 1: Sonar Sweep --- 2 3You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see 4if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying 5into the ocean! 6 7Before you know it, you're inside a submarine the Elves keep ready for situations like this. It's 8covered in Christmas lights (because of course it is), and it even has an experimental antenna that 9should be able to track the keys if you can boost its signal strength high enough; there's a little 10meter that indicates the antenna's signal strength by displaying 0-50 [1m[33mstars[0m. 11 12Your instincts tell you that in order to save Christmas, you'll need to get all [1m[33mfifty 13stars[0m by December 25th. 14 15Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent 16calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants 17[1m[33mone star[0m. Good luck! 18 19As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of 20the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each 21line is a measurement of the sea floor depth as the sweep looks further and further away from the 22submarine. 23 24For example, suppose you had the following report: 25 26199 27200 28208 29210 30200 31207 32240 33269 34260 35263 36 37This report indicates that, scanning outward from the submarine, the sonar sweep found depths of 38199, 200, 208, 210, and so on. 39 40The first order of business is to figure out how quickly the depth increases, just so you know what 41you're dealing with - you never know if the keys will get carried into deeper water by an ocean 42current or a fish or something. 43 44To do this, count [1m[37mthe number of times a depth measurement increases[0m from the previous 45measurement. (There is no measurement before the first measurement.) In the example above, the 46changes are as follows: 47 48199 (N/A - no previous measurement) 49200 ([1m[37mincreased[0m) 50208 ([1m[37mincreased[0m) 51210 ([1m[37mincreased[0m) 52200 (decreased) 53207 ([1m[37mincreased[0m) 54240 ([1m[37mincreased[0m) 55269 ([1m[37mincreased[0m) 56260 (decreased) 57263 ([1m[37mincreased[0m) 58 59In this example, there are [1m[37m7[0m measurements that are larger than the previous 60measurement. 61 62[1m[37mHow many measurements are larger than the previous measurement?[0m 63 64