2 use std::collections::HashSet;
4 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
12 let mut connected = HashSet::new();
13 let mut border = HashSet::new();
15 let middle = XYZ{x: 0, y: 0, z: 0};
16 border.insert(middle);
18 while !border.is_empty() && connected.len() < 10000 {
19 let choice = *(border.iter().next().unwrap());
20 border.remove(&choice);
21 connected.insert(choice);
23 let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z};
24 let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z};
25 let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z};
26 let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z};
27 let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1};
28 let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1};
30 if !connected.contains(&cxp) {
33 if !connected.contains(&cxm){
36 if !connected.contains(&cyp){
39 if !connected.contains(&cym) {
42 if !connected.contains(&czp){
45 if !connected.contains(&czm) {