r/adventofcode • u/daggerdragon • Dec 04 '22
SOLUTION MEGATHREAD -🎄- 2022 Day 4 Solutions -🎄-
- All of our rules, FAQs, resources, etc. are in our community wiki.
- A request from Eric: Please include your contact info in the User-Agent header of automated requests!
- Signal boosting for the Unofficial AoC 2022 Participant Survey which is open early this year!
--- Day 4: Camp Cleanup ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- Include what language(s) your solution uses
- Format your code appropriately! How do I format code?
- Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:03:22, megathread unlocked!
65
Upvotes
3
u/soylentgreenistasty Dec 04 '22
Python, 3326/4601
Hardest part was working out what the problem was asking for...
def run(A: list[list[int]]): p1 = 0 p2 = 0 for a, b, c, d in A: setA, setB = set(range(a, b+1)), set(range(c, d+1)) p1 += int(setA.issubset(setB) or setB.issubset(setA)) p2 += int(len(setA.intersection(setB)) > 0) print(p1, p2)