diff --git a/044/main.rs b/044/main.rs new file mode 100644 index 0000000..715dde4 --- /dev/null +++ b/044/main.rs @@ -0,0 +1,31 @@ +use std::collections::HashSet; + +fn main() { + let mut hs = HashSet::new(); + for n in 1..10000 { + let pn = n * ( 3*n -1 ) / 2; + hs.insert(pn); + } + let mut D = 10000000; + for p in hs.iter() { + for q in hs.iter() { + if q <= p { + continue; + } + + let s = *p + *q; + if !hs.contains(&s) { + continue; + } + let d = *q - *p; + if !hs.contains(&d) { + continue; + } + if d < D { + D = d; + } + } + } + println!("{}", D); + +}