In [62]:
myinput = '/home/fmuinos/projects/adventofcode/2016/ferran/inputs/input20.txt'
In [63]:
def min_func(myinput):
mylist = []
with open(myinput, 'rt') as f:
for line in f:
mylist.append([int(i) for i in line.rstrip().split('-')])
return sorted(mylist, key=lambda x: x[0])
def min_func(l):
c = 0
for i in range(len(l)):
a, b = l.pop(0)
if a <= c <= b:
c = b + 1
return c
In [64]:
l = parse(myinput)
print(min_func(l))
In [65]:
upper_limit = 4294967295
In [66]:
def allowed(l):
c = -1
white = upper_limit + 1
for i in range(len(l)):
a, b = l.pop(0)
if a <= c <= b:
white -= b - c
c = b
elif c < a:
white -= b - a + 1
c = b
return white
In [67]:
l = parse(myinput)
print(allowed(l))