Advertisement
makut

THIRF

Apr 16th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. from collections import deque
  2. import sys
  3.  
  4. STEPS = 10 ** 6
  5. FIRST = 0
  6. SECOND = 1
  7.  
  8.  
  9. first = deque(list(map(int, input().split())))
  10. second = deque(list(map(int, input().split())))
  11. for i in range(STEPS):
  12.     if not second:
  13.         print('first ', i)
  14.         sys.exit()
  15.     elif not first:
  16.         print('second ', i)
  17.         sys.exit()
  18.     else:
  19.         game = [first.popleft(), second.popleft()]
  20.         if game[FIRST] == 0 and game[SECOND] == 9:
  21.             first.append(game[FIRST])
  22.             first.append(game[SECOND])
  23.         elif game[FIRST] == 9 and game[SECOND] == 0:
  24.             second.append(game[FIRST])
  25.             second.append(game[SECOND])
  26.         elif game[FIRST] > game[SECOND]:
  27.             first.append(game[FIRST])
  28.             first.append(game[SECOND])
  29.         elif game[FIRST] < game[SECOND]:
  30.             second.append(game[FIRST])
  31.             second.append(game[SECOND])            
  32. print('botva')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement