fn count_n_digits_on_layer(&self, n: u8, layer: usize) -> usize {
        /*let height = self[layer].len();
        let width  = self[layer][0].len();
        let mut count_ns = 0;
        for row in 0..height {
            println!("{}", count_ns);
            count_ns += self[layer][row].iter()
                .fold(0, |acc, &x| {
                    if n == x {
                        acc + 1
                    } else {
                        acc
                    }});
            for column in 0..width {
                if n == self[layer][row][column] {
                    count_ns += 1;
                }
            }
        }
        count_ns;*/
        self[layer].iter() // Iterate over each row.
                   .fold(0, |count_0s, row| {
                       count_0s + row.iter() // Iterate over each element.
                                     .fold(0, |count_0s, &elem| {
                                         // Count matching elements.
                                         if n == elem {
                                             count_0s + 1
                                         } else {
                                             count_0s
                                         }})})
    }
// Count the number of `n` digits on a given layer.
Count the number of `n` digits on a given layer.
Count the number of ` n ` digits on a given layer .
fn count_n_digits_on_layer(&self, n: u8, layer: usize) -> usize {
        /*let height = self[layer].len();
        let width  = self[layer][0].len();
        let mut count_ns = 0;
        for row in 0..height {
            println!("{}", count_ns);
            count_ns += self[layer][row].iter()
                .fold(0, |acc, &x| {
                    if n == x {
                        acc + 1
                    } else {
                        acc
                    }});
            for column in 0..width {
                if n == self[layer][row][column] {
                    count_ns += 1;
                }
            }
        }
        count_ns;*/
        self[layer].iter() // Iterate over each row.
                   .fold(0, |count_0s, row| {
                       count_0s + row.iter() // Iterate over each element.
                                     .fold(0, |count_0s, &elem| {
                                         // Count matching elements.
                                         if n == elem {
                                             count_0s + 1
                                         } else {
                                             count_0s
                                         }})})
    }
fn count_n_digits_on_layer ( & self , n : u8 , layer : usize ) -> usize { /*let height = self[layer].len();
        let width  = self[layer][0].len();
        let mut count_ns = 0;
        for row in 0..height {
            println!("{}", count_ns);
            count_ns += self[layer][row].iter()
                .fold(0, |acc, &x| {
                    if n == x {
                        acc + 1
                    } else {
                        acc
                    }});
            for column in 0..width {
                if n == self[layer][row][column] {
                    count_ns += 1;
                }
            }
        }
        count_ns;*/ self [ layer ] . iter ( ) // Iterate over each row. . fold ( 0 , | count_0s , row | { count_0s + row . iter ( ) // Iterate over each element. . fold ( 0 , | count_0s , & elem | { // Count matching elements. if n == elem { count_0s + 1 } else { count_0s } } ) } ) }
Count the number of `n` digits on a given layer.
Count the number of ` n ` digits on a given layer .
&self
n
u8
layer
usize