Last active
April 1, 2017 10:45
-
-
Save juanarrivillaga/ccccc7c2a15bf000692531d0dc950c4c to your computer and use it in GitHub Desktop.
This file contains 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
n = """12 | |
insert 0 5 | |
insert 1 10 | |
insert 0 6 | |
remove 6 | |
append 9 | |
append 1 | |
sort | |
pop | |
reverse | |
print""" | |
def handle_command(lst, command, args): | |
if command != 'print': | |
getattr(lst, command)(*args) | |
else: | |
print lst | |
for line in n.splitlines()[1:]: # skip first line | |
line = line.split() | |
command = line[0].strip() | |
args = map(int, line[1:]) | |
handle_command(lst, command, args) | |
# OUTPUT: | |
# [6, 5, 10] | |
# [1, 5, 9, 10] | |
# [9, 5, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment