From baaf922cdecc25d540b5f1a6ed5b93b734a9cd55 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Wed, 3 Jan 2024 18:26:22 +0000 Subject: [PATCH] 052 ok --- 052/main.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 052/main.rs diff --git a/052/main.rs b/052/main.rs new file mode 100644 index 0000000..4563581 --- /dev/null +++ b/052/main.rs @@ -0,0 +1,39 @@ +use std::collections::HashMap; +fn get_hs(n: u32) -> HashMap { + let mut nn = n; + let mut res = HashMap::::new(); + while nn > 0 { + let c = (nn%10) as u8; + if res.contains_key(&c) { + res.insert(c, res[&c] + 1); + } else { + res.insert(c, 1); + } + nn /= 10; + } + return res; +} + + +fn test(n: u32) -> bool { + let hm = get_hs(n); + for i in 2..=6 { + let m = n * i; + let hmi = get_hs(m); + if hmi != hm { + return false; + } + } + return true; +} + +fn main() { + for i in 1..999999 { + + if test(i) { + println!("{}", i); + break; + } + } + +}