From 4c6bfa1821b334954a9f63bb6ee1b451d84d247c Mon Sep 17 00:00:00 2001 From: evan hemsley Date: Thu, 20 Sep 2018 03:38:09 -0700 Subject: [PATCH] rust! --- .gitignore | 1 + rust/Cargo.lock | 4 ++++ rust/Cargo.toml | 6 ++++++ rust/src/euler/mod.rs | 1 + rust/src/euler/problem_001.rs | 13 +++++++++++++ rust/src/lib.rs | 1 + 6 files changed, 26 insertions(+) create mode 100644 rust/Cargo.lock create mode 100644 rust/Cargo.toml create mode 100644 rust/src/euler/mod.rs create mode 100644 rust/src/euler/problem_001.rs create mode 100644 rust/src/lib.rs 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;