Mars Exploration

  • + 0 comments

    My rust solution:

     const SOS_LEN: usize = 3;
    
    fn marsExploration(s: &str) -> i32 {
        (0..s.len())
            .step_by(3)
            .map(|i| {
                s[i..i + 3].bytes()
                    .zip([b'S', b'O', b'S'])
                    .filter(|&zip| zip.0 != zip.1)
                    .count() as i32
            })
            .sum()
    }