From cd051d35fbcb47aca082ab8ed65618f899e948c8 Mon Sep 17 00:00:00 2001 From: "Sina M. Omrani" Date: Sat, 12 Aug 2023 18:02:51 +0330 Subject: [PATCH] two digits no zero in idiomatic rust --- .../solve-(idiomatic_rust)-huzwares.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 math/111-999-two-digits-no-zero/solve-(idiomatic_rust)-huzwares.rs diff --git a/math/111-999-two-digits-no-zero/solve-(idiomatic_rust)-huzwares.rs b/math/111-999-two-digits-no-zero/solve-(idiomatic_rust)-huzwares.rs new file mode 100644 index 0000000..e4a2465 --- /dev/null +++ b/math/111-999-two-digits-no-zero/solve-(idiomatic_rust)-huzwares.rs @@ -0,0 +1,12 @@ +use std::collections::HashSet; + +fn main() { + // Idiomatic Rust + let counter = (100..1000) + .filter(|&n| { + let n = n.to_string().chars().collect::>(); + !n.contains(&'0') && n.len() == 2 + }) + .count(); + println!("{counter}"); +}