summaryrefslogtreecommitdiff
path: root/fizz-buzz/src/main.rs
blob: c6abf23526a2f555bd61816053cfe51cfe28f6e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    println!("Hello, world!");
}

impl Solution {
    pub fn fizz_buzz(n: i32) -> Vec<String> {
        (1..=n).map(|x| match x {
            i if i % 3 == 0 && x % 5 == 0 => "FizzBuzz".to_string(),
            i if i % 3 == 0 => "Fizz".to_string(),
            i if i % 5 == 0 => "Buzz".to_string(),
            i => i.to_string()
        }).collect()
    }
}