pub fn voting_rules(grid: Vec<Vec<bool>>) -> Vec<Vec<bool>> {
let h = grid.len();
let w = grid[0].len();
let mut new = vec![vec![false; w]; h];
for i in 1..(w - 1) {
for j in 1..(h - 1) {
// neighbour
let mut count = 0;
for k in (i - 1)..(i + 1) {
for l in (j - 1)..(j + 1) {
count += grid[k][l] as usize;
}
}
new[i][j] = count >= 5;
}
}
new
}