+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
38c0746
master
1def follow (n ): 2visited = set ([n ]) 3examine = [n ] 4while len (examine )> 0 : 5for i in pipes [examine .pop ()]: 6if i not in visited : 7visited .add (i ) 8examine .append (i ) 9return visited 10 11pipes = [map (int , [i .strip (',' )for i in x .split ()][2 :])for x in open ("input.txt" )] 12 13"Part 1:" ,len (follow (0 )) 14 15pids = set (range (len (pipes ))) 16groups = 0 17while len (pids )> 0 : 18groups += 1 19pids -= follow (pids .pop ()) 20 21"Part 2:" ,groups