Guest User

Untitled

a guest
Dec 13th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. ########################################################################
  2. #
  3. # Part 1: Run `cart_tick` until a collision occurs, and report the
  4. # location of the collision.
  5.  
  6. part_1 = lambda input_data: (
  7. (
  8. (collision % width, collision // width)
  9. for (tracks, carts, next_turns, width, height) in [
  10. itertools.dropwhile(
  11. lambda current_state: (
  12. 'X' not in current_state[1]
  13. )
  14. ,
  15. accumulate(
  16. itertools.chain(
  17. (input_data,)
  18. ,
  19. itertools.count(1)
  20. )
  21. ,
  22. lambda current_state, tick_number: (
  23. cart_tick(current_state)
  24. )
  25. )
  26. ).next()
  27. ]
  28. for collision in [
  29. carts.index('X')
  30. ]
  31. ).next()
  32. )
Add Comment
Please, Sign In to add comment