Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('input.txt')
- f_out = open('output.txt', 'w')
- d = []
- for line in f:
- if (line[1:3] in d) or ((d == []) and (line[0] == '/')) or ((d == []) and (line[0] == '^')):
- f_out.write('ERROR')
- exit()
- if (line[0] == '+'):
- d.insert(0, line[1:3])
- elif (line[0] == '#'):
- d.append(line[1:3])
- elif (line[0] == '^'):
- d.pop(0)
- elif (line[0] == '/'):
- d.pop()
- if (not d):
- f_out.write('EMPTY')
- else:
- f_out.write(' '.join(d))
- f.close()
- f_out.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement