pub fn crossing_by_wires(grids: &Vec<Grid>) -> u32 {
    let mut cross_grid = Grid::new();
    // First, layout the grid with all wires
    for grid in grids {
        for point in grid.keys() {
            let cross_point = cross_grid.entry(*point).or_insert(0);
            *cross_point += 1;
        }
    }

    // Next, find all points where all wires overlap, and check distance
    let mut distance: u32 = 0;
    let wire_count = grids.len() as u32;
    for key in cross_grid.keys() {
        if cross_grid[key] != wire_count {
            continue;
        }
        let this_distance = grids.iter().fold(0, |sum, g| sum + g[key]);
        if distance == 0 || this_distance < distance {
            distance = this_distance;
        }
    }
    distance
}
/// Given a set of wires (`Grid`s), return the shortest distance where they all intersect
Given a set of wires (`Grid`s), return the shortest distance where they all intersect
Given a set of wires ( ` Grid ` s ) return the shortest distance where they all intersect
pub fn crossing_by_wires(grids: &Vec<Grid>) -> u32 {
    let mut cross_grid = Grid::new();
    // First, layout the grid with all wires
    for grid in grids {
        for point in grid.keys() {
            let cross_point = cross_grid.entry(*point).or_insert(0);
            *cross_point += 1;
        }
    }
    // Next, find all points where all wires overlap, and check distance
    let mut distance: u32 = 0;
    let wire_count = grids.len() as u32;
    for key in cross_grid.keys() {
        if cross_grid[key] != wire_count {
            continue;
        }
        let this_distance = grids.iter().fold(0, |sum, g| sum + g[key]);
        if distance == 0 || this_distance < distance {
            distance = this_distance;
        }
    }
    distance
}
pub fn crossing_by_wires ( grids : & Vec < Grid > ) -> u32 { let mut cross_grid = Grid :: new ( ) ; // First, layout the grid with all wires for grid in grids { for point in grid . keys ( ) { let cross_point = cross_grid . entry ( * point ) . or_insert ( 0 ) ; * cross_point += 1 ; } } // Next, find all points where all wires overlap, and check distance let mut distance : u32 = 0 ; let wire_count = grids . len ( ) as u32 ; for key in cross_grid . keys ( ) { if cross_grid [ key ] != wire_count { continue ; } let this_distance = grids . iter ( ) . fold ( 0 , | sum , g | sum + g [ key ] ) ; if distance == 0 || this_distance < distance { distance = this_distance ; } } distance }
Given a set of wires (`Grid`s), return the shortest distance where they all intersect
Given a set of wires ( ` Grid ` s ) return the shortest distance where they all intersect
grids
&Vec<Grid>
grids
&Vec<Grid>