MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / remove_component

Function remove_component

2021/src/bin/09.rs:15–22  ·  view source on GitHub ↗
((x,y): (usize,usize), coords: &mut HashSet<(usize,usize)>)

Source from the content-addressed store, hash-verified

13}
14
15fn remove_component((x,y): (usize,usize), coords: &mut HashSet<(usize,usize)>) -> usize {
16 if !coords.remove(&(x,y)) {
17 return 0;
18 }
19 1 + [(x-1,y),(x+1,y),(x,y-1),(x,y+1)].iter()
20 .map(|&neighbour| remove_component(neighbour, coords))
21 .sum::<usize>()
22}
23
24fn part2(grid: &[Vec<u8>]) -> usize {
25 let mut points = (0..grid[0].len()).cartesian_product(0..grid.len())

Callers 1

part2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected