Day 1 part 2
parent
73246304f5
commit
8a2cc7c6bf
|
|
@ -47,7 +47,29 @@ fn part_1() {
|
||||||
println!("{}", counter);
|
println!("{}", counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn part_2() {
|
||||||
|
let input = parse_input();
|
||||||
|
let mut dial = 50;
|
||||||
|
|
||||||
|
let mut counter = 0;
|
||||||
|
for (dir, steps) in input {
|
||||||
|
for _ in 0..steps {
|
||||||
|
dial += match dir {
|
||||||
|
Direction::LEFT => -1,
|
||||||
|
Direction::RIGHT => 1,
|
||||||
|
};
|
||||||
|
dial = dial % 100;
|
||||||
|
if dial == 0 {
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("{}", counter);
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Part 1:");
|
println!("Part 1:");
|
||||||
part_1();
|
part_1();
|
||||||
|
println!("Part 2:");
|
||||||
|
part_2();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue