refactored project structure
This commit is contained in:
20
src/day01/part01a.rs
Normal file
20
src/day01/part01a.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
pub fn solve(puzzle: String) -> u64 {
|
||||
let mut solution: u64 = 0;
|
||||
|
||||
let mut dial: i32 = 50;
|
||||
puzzle.split("\n").enumerate().for_each(|(_, line)| {
|
||||
let direction: i32 = match &line[0..1] {
|
||||
"L" => -1,
|
||||
"R" => 1,
|
||||
_ => 0,
|
||||
};
|
||||
dial += direction * line[1..line.len()].parse::<i32>().unwrap();
|
||||
dial %= 100;
|
||||
if dial == 0 {
|
||||
solution += 1;
|
||||
}
|
||||
});
|
||||
|
||||
solution
|
||||
}
|
||||
Reference in New Issue
Block a user