Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Digit Stack by smilicic
def digit_stack(commands):
stack=[]
def push(comm):
stack.append(int(comm[1]))
return 0
def pop(comm):
if stack:
return stack.pop()
return 0
def peek(comm):
if stack:
return stack[-1]
return 0
calls={'PEEK':peek,'POP':pop,'PUSH':push}
return sum(calls[command.split(' ')[0]](command.split(' ')) for command in commands)
July 30, 2014
Comments: