Coin de Gamma
2 years ago
1 changed files with 43 additions and 0 deletions
@ -0,0 +1,43 @@
|
||||
//use std::iter::zip;
|
||||
|
||||
fn is_polindrome(n: i32) -> bool { |
||||
let s = n.to_string(); |
||||
for (p, q) in s.chars().zip(s.chars().rev()) { |
||||
// println!("-{}-{}-", p, q);
|
||||
if q != p { return false; } |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
fn main() { |
||||
|
||||
//let nnnn = 999 * 999 * 999;
|
||||
//let m_nnn = u32::MAX;
|
||||
//println!("{} vs {}", nnnn, m_nnn);
|
||||
let n = 999; |
||||
|
||||
//let mut i = n;
|
||||
//let mut j = n;
|
||||
//let mut k = n;
|
||||
|
||||
let mut best_i = 1; |
||||
let mut best_j = 1; |
||||
|
||||
let mut best_poli = 1; |
||||
|
||||
for i in 100..=n { |
||||
for j in 100..=n { |
||||
let m = i * j; |
||||
if is_polindrome(m) { |
||||
if m > best_poli { |
||||
best_poli = m; |
||||
best_i = i; |
||||
best_j = j; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
println!("{}*{}={}", best_i, best_j, best_poli); |
||||
//let p = is_polindrome(999 * 999 * 999);
|
||||
//println!("{}", p);
|
||||
} |
Loading…
Reference in new issue