+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
6e46de2
master
1points = {tuple (map (int ,l .split ("," )))for l in open ("input" )} 2total = 0 3adj = ((- 1 ,0 ,0 ), (1 ,0 ,0 ), (0 ,- 1 ,0 ), (0 ,1 ,0 ), (0 ,0 ,- 1 ), (0 ,0 ,1 )) 4neighbors = lambda p :tuple ((p [0 ]+ x ,p [1 ]+ y ,p [2 ]+ z )for x ,y ,z in adj ) 5for p in points : 6total += sum (n not in points for n in neighbors (p )) 7total ) 8visited = set () 9q = {(0 ,0 ,0 )} 10total = 0 11while q : 12p = q .pop () 13visited .add (p ) 14for n in neighbors (p ): 15if n in visited or any (i not in range (- 1 ,21 )for i in n ): 16continue 17if n in points : 18total += 1 19continue 20q .add (n ) 21total )