Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
5-liner: 3 lambdas solution in Creative category for Digit Stack by przemyslaw.daniel
def digit_stack(cmds, s=[]):
e, s = {"PU": lambda x: s.append(x.split()[1]) == 1,
"PO": lambda x: s.pop() if s else 0,
"PE": lambda x: s[len(s)-1] if s else 0}, []
return sum([int(e[x[:2]](x)) for x in cmds])
April 27, 2017
Comments: