Skip to content

Instantly share code, notes, and snippets.

@mumbleskates
Last active March 12, 2016 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mumbleskates/586c667c429fcaa9b5b5 to your computer and use it in GitHub Desktop.
Save mumbleskates/586c667c429fcaa9b5b5 to your computer and use it in GitHub Desktop.
def minimum(stack):
gotten = []
try:
while True:
gotten.append(stack.pop())
except ValueError:
pass
if not gotten:
return 0
result = min(gotten)
# stack is empty, recreate it
while gotten:
stack.push(gotten.pop())
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment