-
-
Save solson/e516790fb70fdbc8f31f669dd68d2bcd to your computer and use it in GitHub Desktop.
Rust code shared from the playground
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
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