Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- worms = [int(worm) for worm in input().split()]
- holes = deque(int(hole) for hole in input().split())
- matches = 0
- total_worms_count = len(worms)
- while worms and holes:
- worm = worms.pop()
- hole = holes.popleft()
- if worm <= 0:
- holes.appendleft(hole)
- continue
- if worm == hole:
- matches += 1
- else:
- worm -= 3
- worms.append(worm)
- matched_result = f"Matches: {matches}" if matches > 0 else "There are no matches."
- print(matched_result)
- if total_worms_count == matches:
- print("Every worm found a suitable hole!")
- elif worms:
- print(f"Worms left: {', '.join(str(w) for w in worms)}")
- else:
- print("Worms left: none")
- if not holes:
- print("Holes left: none")
- else:
- print(f"Holes left: {', '.join(str(h) for h in holes)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement