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.

Do they get harder at some point? Since the timing format is very euromisic I'm just aiming to complete every challenge before the next one drops.

import re
foo = []
with open('day4_input.txt', 'r') as inp:
    foo = inp.read().split('\n')
total1, total2 = 0, 0
for f in foo:
    f = [eval(x) for x in re.split(',|-', f)]
    if (f[0] <= f[2] <= f[3] <= f[1]) or (f[2] <= f[0] <= f[1] <= f[3]):
        total1 += 1
    if not (f[2] > f[1] or f[0] > f[3]):
        total2 += 1
print(total1, total2)
Jump in the discussion.

No email address required.

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