Function advent_solutions::advent2017::day12::part1 [] [src]

pub fn part1(connections: &HashMap<usize, Vec<usize>>) -> usize

You need to figure out how many programs are in the group that contains program ID 0.

For example, suppose you go door-to-door like a travelling salesman and record the following list:

0 <-> 2
1 <-> 1
2 <-> 0, 3, 4
3 <-> 2, 4
4 <-> 2, 3, 6
5 <-> 6
6 <-> 4, 5

In this example, the following programs are in the group that contains program ID 0:

Therefore, a total of 6 programs are in this group; all but program 1, which has a pipe that connects it to itself.

let connections = parse_connections(input)
    .to_full_result()
    .expect("Error parsing connections");

assert_eq!(part1(&connections), 6);

How many programs are in the group that contains program ID 0?