The Day 03 challenge involves the calculating whether a character symbol is adjacent to a part number in a two dimensional map, such as:
467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..
and then doing things with the part numbers.
To calculate whether a symbol is adjacent to a part number we’re going to need:
- the position of each symbol,
- the position of each number,
- the length of the token for each number.
Tokenising the input
The simplest way to get this data that I can think of is to parse the map into a list of tokens, where the number and blank tokens contain the info for me to know the length (ie. the &str
).