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.

had important business to attend to today sorry I'm late boss here's the homework. Bodged together at 11:30pm as usual

file = open("input.txt")
cc = 0
co = 0
for line in file:
    line = line.rstrip()
    h_i = [i for i, x in enumerate(line) if x == '-']
    c_i = [i for i, x in enumerate(line) if x == ',']
    e1_min = int(line[0:h_i[0]])
    e1_max = int(line[h_i[0]+1:c_i[0]])
    e2_min = int(line[c_i[0]+1:h_i[1]])
    e2_max = int(line[h_i[1]+1:len(line)])
    if ((e1_min <= e2_min and e1_max>=e2_max) or (e2_min <= e1_min and e2_max>=e1_max)):
        cc += 1
    if not ((e1_max < e2_min) or (e2_max < e1_min)):
        co += 1
print(cc)
print(co)
Jump in the discussion.

No email address required.



Now playing: Northern Hemispheres (DKC).mp3

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