Reupload to new git vps.
This commit is contained in:
commit
463b76e6aa
4 changed files with 45 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "FizzBuzz"
|
||||||
|
version = "0.1.0"
|
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "FizzBuzz"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
31
src/main.rs
Normal file
31
src/main.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
fn fizz_buzz(current_number: u32) -> String {
|
||||||
|
let mut rules = BTreeMap::new();
|
||||||
|
rules.insert(3, "Fizz");
|
||||||
|
rules.insert(5, "Buzz");
|
||||||
|
// Add more rules here!
|
||||||
|
|
||||||
|
let result: String = rules
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(&divisor, &word)| {
|
||||||
|
if current_number % divisor == 0 {
|
||||||
|
Some(word)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if result.is_empty() {
|
||||||
|
current_number.to_string()
|
||||||
|
} else {
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
for i in 1..=100 {
|
||||||
|
println!("{}", fizz_buzz(i));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue