Skip to content

Instantly share code, notes, and snippets.

@andriiburka
Last active May 3, 2020 18:33
Show Gist options
  • Save andriiburka/d21f3284a7e358d3e699037ced0592b4 to your computer and use it in GitHub Desktop.
Save andriiburka/d21f3284a7e358d3e699037ced0592b4 to your computer and use it in GitHub Desktop.
# QUEUES
from collections import deque
total_liters = int(input())
people = deque()
while True:
# Name or END command
cmd = input()
if cmd == "Start":
while True:
cmd2 = input()
if cmd2 == "End":
print(f"{total_liters} liters left")
break
if "refill" in cmd2:
cmd2 = cmd2.split()[1]
total_liters += int(cmd2)
elif cmd2.isdigit():
print(f"{people[0]} got water")
people.popleft()
print(people)
total_liters -= int(cmd2)
else:
people.append(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment