Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################
- #
- # Process input data to return the appropriate records or data format.
- #
- # For this puzzle, the input data will be a 4-item tuple:
- # `(tracks, carts, next_turns, width, height)`
- # - `tracks` holds the tracks of the puzzle as a single string (with the
- # first `width` characters holding the first row of the puzzle, etc).
- # Any place in the original puzzle input which held a cart is replaced
- # by the track that underlies it.
- # - `carts` holds the carts from the puzzle in a string the same size as
- # `tracks`. Each location of the original puzzle that has a cart will
- # have a track in `tracks` and a cart direction (^/v/>/<) in `carts`;
- # all other locations will have the original puzzle content in `tracks`
- # and a space in `carts`.
- # - `next_turns` holds the next turn direction for each cart in `carts`,
- # with each cart starting out with a next turn of `1`. Any location in
- # `carts` which does not hold a cart will have a space in `next_turns`.
- # - `width` and `height` are the number of columns and number of rows,
- # respectively, in the input data.
- process_input_data = lambda input_data: (
- input_data
- .replace('\n', '')
- .replace('<', '-')
- .replace('>', '-')
- .replace('^', '|')
- .replace('v', '|')
- ,
- input_data
- .replace('\n', '')
- .replace('-', ' ')
- .replace('|', ' ')
- .replace('+', ' ')
- .replace('\\', ' ')
- .replace('/', ' ')
- ,
- input_data
- .replace('\n', '')
- .replace('-', ' ')
- .replace('|', ' ')
- .replace('+', ' ')
- .replace('\\', ' ')
- .replace('/', ' ')
- .replace('<', '1')
- .replace('>', '1')
- .replace('^', '1')
- .replace('v', '1')
- ,
- len(input_data.split('\n')[0]),
- len(input_data.split('\n'))
- )
Add Comment
Please, Sign In to add comment