Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ლ(▀̿̿Ĺ̯̿̿▀̿ლ) solution in Clear category for Digit Stack by vmiimu
def digit_stack(commands):
stack, total = [], 0
for c in commands:
x = c[:2]
if x == 'PU':
stack.append(int(c[-1]))
elif x == 'PO' and stack:
total += stack.pop()
elif x == 'PE' and stack:
total += stack[-1]
return total
Jan. 24, 2019
Comments: