heh
2015/25!
| -rw-r--r-- | src/main.rs | 23 | ||||
| -rw-r--r-- | src/util.rs | 15 |
2 files changed, 17 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index efed8c5..b2aa746 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ mixed_script_confusables, static_mut_refs, incomplete_features, + unused_imports, redundant_semicolons )] #![feature( @@ -48,22 +49,12 @@ type u32x3 = Simd<u32, 3>; #[no_mangle] pub fn p1(x: &'static str) -> impl Display { - let wat = [ - 1u128, 3, 5, 11, 13, 17, 19, 23, 29, 31, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, - 97, 101, 103, 107, 109, 113, - ]; - let n = wat.sum() / 4; - (1..wat.len()) - .flat_map(|c| { - wat.iter() - .copied() - .combinations(c) - .filter(move |x| x.iter().sum::<u128>() == n) - .map(|x| x.iter().product::<u128>()) - }) - .Δ() - // .min() - // .ψ() + let (ro, co) = (2947u64, 3029u64); + // count diagonals + let point = (0..ro + co - 1).sum::<u64>() + co; + infinite_successors(20151125u64, |x| (x * 252533).rem_euclid(33554393)) + .nth(point as usize - 1) + .unwrap() } fn main() { diff --git a/src/util.rs b/src/util.rs index 9c815eb..30e5d53 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,6 +3,7 @@ use regex::Regex; use rustc_hash::FxHashMap as HashMap; use rustc_hash::FxHashSet as HashSet; +use std::iter::successors; use std::sync::LazyLock; use std::{ cmp::Reverse, @@ -18,11 +19,11 @@ pub mod prelude { #[allow(unused_imports)] pub(crate) use super::{bits, dang, leek, mat, shucks, C}; pub use super::{ - even, gcd, gt, l, lcm, lt, nail, pa, r, rand, reading, reading::Ext, sort, twice, - DigiCount, Dir, FilterBy, FilterBy3, GreekTools, IntoCombinations, IntoLines, IterͶ, - NumTupleIterTools, ParseIter, Printable, Skip, SplitU8, Str, TakeLine, TupleIterTools2, - TupleIterTools2R, TupleIterTools3, TupleUtils, UnifiedTupleUtils, UnsoundUtilities, Widen, - Ͷ, Α, Κ, Λ, Μ, + even, gcd, gt, infinite_successors, l, lcm, lt, nail, pa, r, rand, reading, reading::Ext, + sort, twice, DigiCount, Dir, FilterBy, FilterBy3, GreekTools, IntoCombinations, IntoLines, + IterͶ, NumTupleIterTools, ParseIter, Printable, Skip, SplitU8, Str, TakeLine, + TupleIterTools2, TupleIterTools2R, TupleIterTools3, TupleUtils, UnifiedTupleUtils, + UnsoundUtilities, Widen, Ͷ, Α, Κ, Λ, Μ, }; pub use itertools::iproduct; pub use itertools::izip; @@ -1820,3 +1821,7 @@ pub fn nb(x: usize, y: usize) -> [(usize, usize); 8] { pub fn twice<T: Copy>(x: T) -> impl Iterator<Item = T> + Clone + ExactSizeIterator { std::iter::repeat_n(x, 2) } + +pub fn infinite_successors<T: Copy>(x: T, mut f: impl FnMut(T) -> T) -> impl Iterator<Item = T> { + successors(Some(x), move |x| Some(f(*x))) +} |