Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. input = 793061
  2. recipes = [3, 7]
  3. elf1 = 0
  4. elf2 = 1
  5. window = 37
  6. l=2
  7.  
  8. while True:
  9.   score = recipes[elf1] + recipes[elf2]
  10.   if score < 10:
  11.     recipes.append(score)
  12.     window = ((window * 10) + score) % 10000000
  13.     l += 1
  14.   else:
  15.     recipes.extend(divmod(score,10))
  16.     window = ((window * 100) + score) % 10000000
  17.     l += 2
  18.   elf1 = (elf1 + recipes[elf1] + 1) % l
  19.   elf2 = (elf2 + recipes[elf2] + 1) % l
  20.   if input == int(window/10) or input == window:
  21.     break
  22.  
  23. print(l-6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement