problem 3 - shortened

This commit is contained in:
Stefan Harmuth 2025-03-19 11:33:00 +01:00
parent ab587caee4
commit 028df5de61

View File

@ -11,14 +11,8 @@ for line in my_input:
p1 += l_high - l_low + 1 p1 += l_high - l_low + 1
p1 += r_high - r_low + 1 p1 += r_high - r_low + 1
if r_low < l_low: this_box_set = set(range(l_low, l_high + 1))
l_low, l_high, r_low, r_high = r_low, r_high, l_low, l_high this_box_set |= set(range(r_low, r_high + 1))
if l_high < r_low:
this_box_set = set(range(l_low, l_high + 1))
this_box_set |= set(range(r_low, r_high + 1))
else:
this_box_set = set(range(min(l_low, r_low), max(l_high, r_high) + 1))
p2 += len(this_box_set) p2 += len(this_box_set)
if len(this_box_set | last_boxes) > p3: if len(this_box_set | last_boxes) > p3: