Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Water Jars Simple Transfers solution in Clear category for Water Jars by capback250
def jails(a, b ,q, flag):
ja, jb = 0, 0
steps = []
while q not in [ja, jb]:
if not ja:
ja = a
steps.append('01') if not flag else steps.append('02')
elif jb == b:
jb = 0
steps.append('20') if not flag else steps.append('10')
else:
canFill = b - jb
if ja >= canFill:
ja -= canFill
jb += canFill
else:
tr = ja
jb += ja
ja = 0
steps.append('12') if not flag else steps.append('21')
return steps
def checkio(a, b, c):
return sorted([jails(a, b, c, False), jails(b, a, c, True)], key=len)[0]
Jan. 24, 2016