Last active
March 12, 2016 05:10
-
-
Save mumbleskates/586c667c429fcaa9b5b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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