Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################
- #
- # Part 1: Run `cart_tick` until a collision occurs, and report the
- # location of the collision.
- part_1 = lambda input_data: (
- (
- (collision % width, collision // width)
- for (tracks, carts, next_turns, width, height) in [
- itertools.dropwhile(
- lambda current_state: (
- 'X' not in current_state[1]
- )
- ,
- accumulate(
- itertools.chain(
- (input_data,)
- ,
- itertools.count(1)
- )
- ,
- lambda current_state, tick_number: (
- cart_tick(current_state)
- )
- )
- ).next()
- ]
- for collision in [
- carts.index('X')
- ]
- ).next()
- )
Add Comment
Please, Sign In to add comment