Created
December 16, 2019 06:50
-
-
Save bwinton/73ff8bbfc577a299ad81260eabcdfafc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This only works if your offset is bigger than half the length of your data… | |
fn run_big_fft(data: &[char], iterations: usize, offset: usize) -> String { | |
let mut curr: Vec<i32> = data | |
.iter() | |
.skip(offset) | |
.map(|&i| i.to_digit(10).unwrap() as i32) | |
.collect(); | |
for _ in 0..iterations { | |
let mut next: Vec<i32> = vec![]; | |
let mut sum: i32 = curr.iter().sum(); | |
for elem in curr { | |
next.push((sum % 10).abs()); | |
sum -= elem; | |
} | |
curr = next; | |
} | |
curr.into_iter().map(|x| x.to_string()).take(8).collect() | |
} | |
fn process_data_b(data: &str) -> String { | |
let offset: usize = data[0..7].parse().unwrap(); | |
run_big_fft( | |
&data.chars().collect::<Vec<_>>().repeat(10_000), | |
100, | |
offset, | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment