Function advent_solutions::advent2017::day24::part1
[−]
[src]
pub fn part1(graph: &Vec<Component>) -> usize
The strength of a bridge is the sum of the port types in each
component. For example, if your bridge is made of components 0/3,
3/7, and 7/4, your bridge has a strength of 0+3 + 3+7 + 7+4 = 24.
For example, suppose you had the following components:
0/2 2/2 2/3 3/4 3/5 0/1 10/1 9/10
With them, you could make the following valid bridges:
-
0/1 -
0/1--10/1 -
0/1--10/1--9/10 -
0/2 -
0/2--2/3 -
0/2--2/3--3/4 -
0/2--2/3--3/5 -
0/2--2/2 -
0/2--2/2--2/3 -
0/2--2/2--2/3--3/4 -
0/2--2/2--2/3--3/5
(Note how, as shown by 10/1, order of ports within a component doesn't
matter. However, you may only use each port on a component once.)
Of these bridges, the strongest one is 0/1--10/1--9/10; it has a
strength of 0+1 + 1+10 + 10+9 = 31.
let input = parse_input("\ 0/2 2/2 2/3 3/4 3/5 0/1 10/1 9/10 "); assert_eq!(part1(&input), 31);
What is the strength of the strongest bridge you can make with the components you have available?