Advertisement
horozov86

Collecting Eggs

Jun 16th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. from collections import deque
  2.  
  3. eggs = deque([int(x) for x in input().split(', ')])
  4. papers = [int(x) for x in input().split(', ')]
  5.  
  6. boxes = 0
  7. while eggs and papers:
  8.     egg = eggs.popleft()
  9.     if egg < 0:
  10.         continue
  11.    
  12.     if egg == 13:
  13.         first_paper = papers[0]
  14.         last_paper = papers[-1]
  15.         papers.append(first_paper)
  16.         papers.insert(0, last_paper)
  17.         continue
  18.    
  19.     paper = papers.pop()
  20.    
  21.     total_sum = egg + paper
  22.    
  23.     if total_sum <= 50:
  24.         boxes += 1
  25.        
  26.     else:
  27.         continue
  28.    
  29. if boxes >= 1:
  30.     print(f"Great! You filled {boxes} boxes.")
  31. else:
  32.     print(f"Sorry! You couldn't fill any boxes!")
  33.    
  34. if eggs:
  35.     print(f"Eggs left: {', '.join([str(x) for x in eggs])}")
  36.    
  37. if papers:
  38.     print(f"Pieces of paper left: {', '.join([str(x) for x in papers])}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement