Unable to load image

Advent of code day 4 :marseysad:

This is the advent of code day 4 thread for bragging about your solution and bullying people who haven't gotten it yet :marseyill:

35
Jump in the discussion.

No email address required.

with open("./input4.txt") as infile:
    ct = 0
    for line in map(str.strip, infile):
        a, b = line.split(',')
        a_min, a_max = map(int, a.split("-"))
        b_min, b_max = map(int, b.split("-"))
        a_set = set(range(a_min, a_max +1))
        b_set = set(range(b_min, b_max +1))
        u = a_set & b_set

        # part one
        # if len(u) in {len(a_set), len(b_set)}:
        #     ct += 1
        
        # part two
        # if u:
        #     ct += 1
    print(ct)
Jump in the discussion.

No email address required.

set(range(b_min, b_max+1))

>tfw I didn't think of this

:#marseyitsover:

Jump in the discussion.

No email address required.



Now playing: Donkey Kong December National Anthem.mp3

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.