Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("{}", raindrops(3));
- }
- pub fn raindrops(n: usize) -> String {
- let sound = (1..=n)
- .filter(|x| n % x == 0)
- .map(|x| match x {
- 7 => "Plong",
- 5 => "Plang",
- 3 => "Pling",
- _ => "",
- })
- .collect::<Vec<&str>>()
- .join("");
- //if sound.is_empty() {
- // n.to_string()
- //} else {
- // sound
- match sound.is_empty() {
- true => n.to_string(),
- false => sound,
- }
- }
Add Comment
Please, Sign In to add comment