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; + } + } + +}