Function advent_solutions::advent2017::day12::part2
[−]
[src]
pub fn part2(connections: &HashMap<usize, Vec<usize>>) -> usize
There are more programs than just the ones in the group containing
program ID 0. The rest of them have no way of reaching that group, and
still might have no way of reaching each other.
A group is a collection of programs that can all communicate via pipes either directly or indirectly. The programs you identified just a moment ago are all part of the same group. Now, they would like you to determine the total number of groups.
In the example above, there were 2 groups: one consisting of programs
0,2,3,4,5,6, and the other consisting solely of program 1.
let input = b"0 <-> 2 1 <-> 1 2 <-> 0, 3, 4 3 <-> 2, 4 4 <-> 2, 3, 6 5 <-> 6 6 <-> 4, 5 "; let connections = parse_connections(input) .to_full_result() .expect("Error parsing connections"); assert_eq!(part2(&connections), 2);
How many groups are there in total?