interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / queue-definition / oracle.py

26 lines · 588 bytes Raw Blame History
1# Independent reference for "Queue/Definition" (Python 3, standard library only).
2# expected.txt is this program's stdout; omc never produced it.
3from collections import deque
4q = deque()
5def empty():
6 print("empty:", "no" if q else "yes")
7def push(v):
8 q.append(v)
9 print("push", v)
10def pop():
11 if not q:
12 print("pop from an empty queue: error")
13 return False
14 print("pop", q.popleft())
15 return True
16empty()
17for i in range(1, 7):
18 push(11 * i)
19for _ in range(4):
20 pop()
21for i in range(7, 12):
22 push(-11 * i)
23empty()
24while pop():
25 pass
26empty()