Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6-liner: my own compressed solution in Creative category for Painting Wall by przemyslaw.daniel
def checkio(r, o):
for i in range(len(o)):
a = {x for x, _ in o[:i+1] if all(x <= a or x >= b for a, b, in o[:i+1])}
b = {x for _, x in o[:i+1] if all(x <= a or x >= b for a, b, in o[:i+1])}
if sum(y-x+1 for x, y in zip(sorted(a-b), sorted(b-a))) >= r: return i+1
return -1
Jan. 16, 2018