This commit is contained in:
timeshifter
2025-03-20 11:15:16 +01:00
parent 8a7f61e253
commit affca52d6a
2 changed files with 31 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "euler41"
version = "0.1.0"
edition = "2024"
[dependencies]
primes = {version = "*", path = "../../lib/primes"}
+24
View File
@@ -0,0 +1,24 @@
use primes::Primes;
fn main() {
let primes = Primes::get_between(2, 7_654_321);
let result = primes
.into_vec()
.into_iter()
.rev()
.filter_map(|number| is_pandigital(&number.to_string()))
.next()
.unwrap();
println!("{result}");
}
fn is_pandigital(s: &str) -> Option<String> {
let length = s.len().to_string().chars().next().unwrap();
for c in '1'..=length {
if !s.contains(c) {
return None;
}
}
Some(s.to_string())
}