use std::fs; fn main() { println!("Day 1P1"); let contents = fs::read_to_string("test").expect("input not found"); let mut value = 50; let mut hits = 0; for line in contents.strip_suffix("\n").unwrap().split("\n") { let mut line_iter = line.chars(); let mut left = true; match line_iter.next().unwrap() { 'R' => { left = false; } 'L' => {} _ => panic!("What the actual fuck"), } let turns_str = line_iter.as_str(); let turns: i64 = turns_str.parse().unwrap(); // There's probably a rust way to not mess with the types here let dir = match left { true => -1, false => 1, }; value = (value + turns * dir) % 100; if value == 0 { hits += 1; } } println!("Yipee {hits}") }