Skip to content

Instantly share code, notes, and snippets.

@juanarrivillaga
Last active April 1, 2017 10:45
Show Gist options
  • Save juanarrivillaga/ccccc7c2a15bf000692531d0dc950c4c to your computer and use it in GitHub Desktop.
Save juanarrivillaga/ccccc7c2a15bf000692531d0dc950c4c to your computer and use it in GitHub Desktop.
n = """12
insert 0 5
insert 1 10
insert 0 6
print
remove 6
append 9
append 1
sort
print
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