Guest User

Untitled

a guest
Dec 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. const _INPUT: &str = "3,4,1,5";
  2. const INPUT: &str = "63,144,180,149,1,255,167,84,125,65,188,0,2,254,229,24";
  3.  
  4. const SIZE: usize = 256;
  5.  
  6. fn main() {
  7. let mut circle: Vec<usize> = (0..SIZE).collect();
  8. let mut pos = 0;
  9. let mut skip_size = 0;
  10.  
  11. for length in INPUT.split(',').map(|n| n.parse::<usize>().unwrap()) {
  12. for i in 0..length / 2 {
  13. circle.swap((pos + i) % SIZE, (pos + length - 1 - i) % SIZE);
  14. }
  15.  
  16. pos += length + skip_size;
  17. skip_size += 1;
  18. }
  19.  
  20. println!("{}", circle[0] * circle[1]);
  21. }
Add Comment
Please, Sign In to add comment