Function advent_solutions::advent2017::day03::part1
[−]
[src]
pub fn part1(index: &usize) -> usize
While this is very space-efficient (no squares are skipped), requested
data must be carried back to square 1 (the location of the only access
port for this memory system) by programs that can only move up, down,
left, or right. They always take the shortest path: the Manhattan
Distance between the location of the data and square 1.
For example:
Data from square
1is carried0steps, since it's at the access port.assert_eq!(part1(&1), 0);
Data from square
12is carried3steps, such as: down, left, left.assert_eq!(part1(&12), 3);
Data from square
23is carried only2steps: up twice.assert_eq!(part1(&23), 2);
Data from square
1024must be carried31steps.assert_eq!(part1(&1024), 31);
How many steps are required to carry the data from the square identified in your puzzle input all the way to the access port?