description.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --- Day 4: Camp Cleanup ---
  2. Space needs to be cleared before the last supplies can be unloaded from the ships, and so several Elves have been assigned the job of cleaning up sections of the camp. Every section has a unique ID number, and each Elf is assigned a range of section IDs.
  3. However, as some of the Elves compare their section assignments with each other, they've noticed that many of the assignments overlap. To try to quickly find overlaps and reduce duplicated effort, the Elves pair up and make a big list of the section assignments for each pair (your puzzle input).
  4. For example, consider the following list of section assignment pairs:
  5. 2-4,6-8
  6. 2-3,4-5
  7. 5-7,7-9
  8. 2-8,3-7
  9. 6-6,4-6
  10. 2-6,4-8
  11. For the first few pairs, this list means:
  12. Within the first pair of Elves, the first Elf was assigned sections 2-4 (sections 2, 3, and 4), while the second Elf was assigned sections 6-8 (sections 6, 7, 8).
  13. The Elves in the second pair were each assigned two sections.
  14. The Elves in the third pair were each assigned three sections: one got sections 5, 6, and 7, while the other also got 7, plus 8 and 9.
  15. This example list uses single-digit section IDs to make it easier to draw; your actual list might contain larger numbers. Visually, these pairs of section assignments look like this:
  16. .234..... 2-4
  17. .....678. 6-8
  18. .23...... 2-3
  19. ...45.... 4-5
  20. ....567.. 5-7
  21. ......789 7-9
  22. .2345678. 2-8
  23. ..34567.. 3-7
  24. .....6... 6-6
  25. ...456... 4-6
  26. .23456... 2-6
  27. ...45678. 4-8
  28. Some of the pairs have noticed that one of their assignments fully contains the other. For example, 2-8 fully contains 3-7, and 6-6 is fully contained by 4-6. In pairs where one assignment fully contains the other, one Elf in the pair would be exclusively cleaning sections their partner will already be cleaning, so these seem like the most in need of reconsideration. In this example, there are 2 such pairs.
  29. In how many assignment pairs does one range fully contain the other?
  30. Your puzzle answer was 441.
  31. --- Part Two ---
  32. It seems like there is still quite a bit of duplicate work planned. Instead, the Elves would like to know the number of pairs that overlap at all.
  33. In the above example, the first two pairs (2-4,6-8 and 2-3,4-5) don't overlap, while the remaining four pairs (5-7,7-9, 2-8,3-7, 6-6,4-6, and 2-6,4-8) do overlap:
  34. 5-7,7-9 overlaps in a single section, 7.
  35. 2-8,3-7 overlaps all of the sections 3 through 7.
  36. 6-6,4-6 overlaps in a single section, 6.
  37. 2-6,4-8 overlaps in sections 4, 5, and 6.
  38. So, in this example, the number of overlapping assignment pairs is 4.
  39. In how many assignment pairs do the ranges overlap?
  40. Your puzzle answer was 861.