(map: &[Vec<char>], portals: &[(String, usize, usize)])
| 181 | } |
| 182 | |
| 183 | fn create_graph(map: &[Vec<char>], portals: &[(String, usize, usize)]) -> Graph { |
| 184 | let mut g = (0..W).cartesian_product(0..H) |
| 185 | .filter(|&(i,j)| map[i][j] == '.') |
| 186 | .map(|(i,j)| { |
| 187 | let neighbours = [(i-1,j), (i+1,j), (i,j-1), (i,j+1)].iter() |
| 188 | .filter(|&&(x,y)| map[x][y] == '.') |
| 189 | .map(|&(x,y)| (x,y,EdgeType::Normal)) |
| 190 | .collect(); |
| 191 | ((i,j), neighbours) |
| 192 | }) |
| 193 | .collect(); |
| 194 | connect_portals(&mut g, portals); |
| 195 | g |
| 196 | } |
| 197 | |
| 198 | fn bfs_part_one(graph: &Graph, (x,y): (usize,usize), goal: (usize,usize)) -> usize { |
| 199 | let mut queue = VecDeque::new(); |
no test coverage detected