heh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![allow(confusable_idents, uncommon_codepoints, mixed_script_confusables)]
#![feature(
    array_windows,
    test,
    slice_as_chunks,
    array_chunks,
    slice_split_once,
    byte_slice_trim_ascii
)]
extern crate test;
mod util;

pub use util::prelude::*;

/// generated by passing 1, 0{20} and 0, 1, 0{19}, etc to the original
const INTERPOLATION_P1: [i32; 21] = [
    1, -21, 210, -1330, 5985, -20349, 54264, -116280, 203490, -293930, 352716, -352716, 293930,
    -203490, 116280, -54264, 20349, -5985, 1330, -210, 21,
];
/// just the reversed version of [`INTERPOLATION_P1`]
const INTERPOLATION_P2: [i32; 21] = [
    21, -210, 1330, -5985, 20349, -54264, 116280, -203490, 293930, -352716, 352716, -293930,
    203490, -116280, 54264, -20349, 5985, -1330, 210, -21, 1,
];

pub fn solve(a: impl Iterator<Item = i32>, interp: [i32; 21]) -> i32 {
    a.zip(interp.into_iter())
        .map(|(a, b)| a as i64 * b as i64)
        .sum::<i64>() as i32
}

pub fn run(i: &str) -> impl Display {
    i.行()
        .map(|x| solve(&mut x.κ(), INTERPOLATION_P2))
        .sum::<i32>()
}

fn main() {
    let i = include_str!("inp.txt").trim();
    println!("{}", run(i));
}

#[bench]
fn bench(b: &mut test::Bencher) {
    let i = boxd(include_str!("inp.txt").trim());
    b.iter(|| run(i));
}