Skip to content

Instantly share code, notes, and snippets.

Created December 15, 2017 22:27
Show Gist options
  • Save anonymous/24a8d341e2b549763ff2bb2d31e6e581 to your computer and use it in GitHub Desktop.
Save anonymous/24a8d341e2b549763ff2bb2d31e6e581 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
const _INPUT: &str = "3,4,1,5";
const INPUT: &str = "63,144,180,149,1,255,167,84,125,65,188,0,2,254,229,24";
const SIZE: usize = 256;
fn main() {
let mut circle: Vec<usize> = (0..SIZE).collect();
let mut pos = 0;
let mut skip_size = 0;
for length in INPUT.split(',').map(|n| n.parse::<usize>().unwrap()) {
for i in 0..length / 2 {
circle.swap((pos + i) % SIZE, (pos + length - 1 - i) % SIZE);
}
pos += length + skip_size;
skip_size += 1;
}
println!("{}", circle[0] * circle[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment