Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
10-liner: nice and clean solution in Clear category for Painting Wall by przemyslaw.daniel
def checkio(required, operations):
for i in range(len(operations)):
left, right, op = [], [], operations[:i+1]
for x, y in op:
left += [x]*all(x <= a or x >= b for a, b, in op)
right += [y]*all(y <= a or y >= b for a, b, in op)
left, right = set(left)-set(right), set(right)-set(left)
current = sum(y-x+1 for x, y in zip(sorted(left), sorted(right)))
if current >= required: return i+1
return -1
Jan. 15, 2018