diff --git a/.gitignore b/.gitignore index 43950d6..1233871 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ c/binaries */bin/* *.dwarf +rust/target diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..aa1924c --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "euler-rust" +version = "0.1.0" + diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..014ac82 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "euler-rust" +version = "0.1.0" +authors = ["evan hemsley "] + +[dependencies] diff --git a/rust/src/euler/mod.rs b/rust/src/euler/mod.rs new file mode 100644 index 0000000..c5d6720 --- /dev/null +++ b/rust/src/euler/mod.rs @@ -0,0 +1 @@ +pub mod problem_001; diff --git a/rust/src/euler/problem_001.rs b/rust/src/euler/problem_001.rs new file mode 100644 index 0000000..127fe03 --- /dev/null +++ b/rust/src/euler/problem_001.rs @@ -0,0 +1,13 @@ +fn solution() -> i32 { + return (1..1000).filter( |n| (n % 3 == 0) || (n % 5 == 0)).sum(); +} + +#[cfg(test)] +mod tests { + use euler::problem_001::solution; + + #[test] + fn problem_001() { + assert_eq!(solution(), 233168); + } +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..f20075a --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1 @@ +pub mod euler;