pub fn solve(input: &str) { let instructions = input.lines().map(|str| { let distance = unsafe { str::from_utf8_unchecked( &str.bytes().collect::>()[1..]).parse::().unwrap() }; if str.bytes().next().unwrap() == b'L' { -distance } else { distance } }).collect::>(); let mut counter = 0; let mut dial = 50; println!("instr min: {}, max: {}", instructions.iter().min().unwrap(), instructions.iter().max().unwrap()); for instruction in instructions { // let old = dial; // let new = dial + instruction; dial += instruction; match dial { ..=-1 => { counter += dial / -100; dial += 100 * (dial / -100); }, 100.. => { counter += dial / 100; dial %= 100; }, _ => {} } // println!("{old} -> {new} = {dial}"); if dial == 0 { // println!("incremented!"); counter += 1; } } println!("counter: {}", counter); }