description.txt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --- Day 5: Hydrothermal Venture ---
  2. You come across a field of hydrothermal vents on the ocean floor! These vents constantly produce large, opaque clouds, so it would be best to avoid them if possible.
  3. They tend to form in lines; the submarine helpfully produces a list of nearby lines of vents (your puzzle input) for you to review. For example:
  4. 0,9 -> 5,9
  5. 8,0 -> 0,8
  6. 9,4 -> 3,4
  7. 2,2 -> 2,1
  8. 7,0 -> 7,4
  9. 6,4 -> 2,0
  10. 0,9 -> 2,9
  11. 3,4 -> 1,4
  12. 0,0 -> 8,8
  13. 5,5 -> 8,2
  14. Each line of vents is given as a line segment in the format x1,y1 -> x2,y2 where x1,y1 are the coordinates of one end the line segment and x2,y2 are the coordinates of the other end. These line segments include the points at both ends. In other words:
  15. An entry like 1,1 -> 1,3 covers points 1,1, 1,2, and 1,3.
  16. An entry like 9,7 -> 7,7 covers points 9,7, 8,7, and 7,7.
  17. For now, only consider horizontal and vertical lines: lines where either x1 = x2 or y1 = y2.
  18. So, the horizontal and vertical lines from the above list would produce the following diagram:
  19. .......1..
  20. ..1....1..
  21. ..1....1..
  22. .......1..
  23. .112111211
  24. ..........
  25. ..........
  26. ..........
  27. ..........
  28. 222111....
  29. In this diagram, the top left corner is 0,0 and the bottom right corner is 9,9. Each position is shown as the number of lines which cover that point or . if no line covers that point. The top-left pair of 1s, for example, comes from 2,2 -> 2,1; the very bottom row is formed by the overlapping lines 0,9 -> 5,9 and 0,9 -> 2,9.
  30. To avoid the most dangerous areas, you need to determine the number of points where at least two lines overlap. In the above example, this is anywhere in the diagram with a 2 or larger - a total of 5 points.
  31. Consider only horizontal and vertical lines. At how many points do at least two lines overlap?
  32. Your puzzle answer was 5280.
  33. --- Part Two ---
  34. Unfortunately, considering only horizontal and vertical lines doesn't give you the full picture; you need to also consider diagonal lines.
  35. Because of the limits of the hydrothermal vent mapping system, the lines in your list will only ever be horizontal, vertical, or a diagonal line at exactly 45 degrees. In other words:
  36. An entry like 1,1 -> 3,3 covers points 1,1, 2,2, and 3,3.
  37. An entry like 9,7 -> 7,9 covers points 9,7, 8,8, and 7,9.
  38. Considering all lines from the above example would now produce the following diagram:
  39. 1.1....11.
  40. .111...2..
  41. ..2.1.111.
  42. ...1.2.2..
  43. .112313211
  44. ...1.2....
  45. ..1...1...
  46. .1.....1..
  47. 1.......1.
  48. 222111....
  49. You still need to determine the number of points where at least two lines overlap. In the above example, this is still anywhere in the diagram with a 2 or larger - now a total of 12 points.
  50. Consider all of the lines. At how many points do at least two lines overlap?
  51. Your puzzle answer was 16716.