Skip to content

Instantly share code, notes, and snippets.

@bwinton
Created December 16, 2019 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwinton/73ff8bbfc577a299ad81260eabcdfafc to your computer and use it in GitHub Desktop.
Save bwinton/73ff8bbfc577a299ad81260eabcdfafc to your computer and use it in GitHub Desktop.
// 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