4 ms·
Where's the answer for day 1, part 2? Here's day 1 - https://github.com/mitchellh/advent-2021-sql/blob/main/day01/answer.sql https://github.com/mitchellh/adven
by aembleton 5y ago
Where's the answer for day 1, part 2? Here's day 1 - https://github.com/mitchellh/advent-2021-sql/blob/main/day01/answer.sql https://github.com/mitchellh/advent-2021-sql/blob/main/day01...
I can't see where it is creating a window of three results to compare against. I guess, you might just be able to change the offset to 3, as the offsets of 1 and 2 will be included in your current window so don't need to be compared.
- jsmeaton 5y agoHeh I wondered the same thing, but the README says he may not complete every challenge. I actually did the first problem in SQL, and learned a bit about window functions and bounding the range it covers: https://github.com/jarshwah/advent-of-code/blob/main/sql/2021/q01.py#L21 https://github.com/jarshwah/advent-of-code/blob/main/sql/202... Though now I know you can ignore the window and just compare against the 3rd offset, the first solution just needs a `LEAD(depth, 3)` to complete the second question. Still - I learned about `RANGE BETWEEN` so I'm calling it a win.