progress
This commit is contained in:
parent
c1700fda5f
commit
1f2d6a2d01
1 changed files with 16 additions and 7 deletions
|
|
@ -30,28 +30,37 @@ fn parse(input: &str) -> Vec<Rotation> {
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part1() -> u32 {
|
fn gaby() -> (u32, u32) {
|
||||||
let input = &load_string("inputs/2025/day1.input");
|
let input = &load_string("inputs/2025/day1.input");
|
||||||
//let input = TEST_INPUT;
|
//let input = TEST_INPUT;
|
||||||
let mut current_rotation = START;
|
let mut current_rotation = START;
|
||||||
let mut result: u32 = 0;
|
let mut result_part1: u32 = 0;
|
||||||
|
let mut result_part2: u32 = 0;
|
||||||
for roation in parse(input).iter() {
|
for roation in parse(input).iter() {
|
||||||
match roation {
|
match roation {
|
||||||
Rotation::Left(amount) => {
|
Rotation::Left(amount) => {
|
||||||
// overflows to the left
|
// overflows to the left
|
||||||
current_rotation = (((current_rotation as i32) - *amount as i32).rem_euclid(100)) as u32;
|
let new = (current_rotation as i32) - *amount as i32;
|
||||||
|
current_rotation = new.rem_euclid(100) as u32;
|
||||||
|
result_part2 += ((new.abs() + if new < 0 {100} else {0}) / 100) as u32;
|
||||||
},
|
},
|
||||||
Rotation::Right(amount) => {
|
Rotation::Right(amount) => {
|
||||||
// overflows to the right
|
// overflows to the right
|
||||||
current_rotation = (((current_rotation as i32) + *amount as i32).rem_euclid(100)) as u32;
|
let new = (current_rotation as i32) + *amount as i32;
|
||||||
|
current_rotation = new.rem_euclid(100) as u32;
|
||||||
|
result_part2 += (new / 100) as u32;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if current_rotation == 0 {
|
if current_rotation == 0 {
|
||||||
result += 1;
|
result_part1 += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
(result_part1, result_part2)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part1() -> u32 {
|
||||||
|
gaby().0
|
||||||
}
|
}
|
||||||
pub fn part2() -> u32 {
|
pub fn part2() -> u32 {
|
||||||
0
|
gaby().1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue