Skip to content

Commit e155302

Browse files
committed
Fix stuff
1 parent ef413c4 commit e155302

2 files changed

Lines changed: 19 additions & 24 deletions

File tree

aoc2025/src/bin/07.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ pub fn part_two(input: &str) -> Option<u64> {
3535
skip -= 1;
3636
for c in skip..width - skip - 1 {
3737
let curr = row[c];
38-
match curr {
39-
b'^' => {
40-
map_counts[c - 1] += map_counts[c];
41-
map_counts[c + 1] += map_counts[c];
42-
map_counts[c] = 0;
43-
}
44-
_ => (),
38+
if curr == b'^' {
39+
map_counts[c - 1] += map_counts[c];
40+
map_counts[c + 1] += map_counts[c];
41+
map_counts[c] = 0;
4542
}
4643
}
4744
}
@@ -70,9 +67,7 @@ pub fn part_two_original(input: &str) -> Option<u64> {
7067
_ => (),
7168
}
7269
}
73-
let temp = map_counts;
74-
map_counts = new_map_counts;
75-
new_map_counts = temp;
70+
std::mem::swap(&mut map_counts, &mut new_map_counts);
7671
if skip != 0 {
7772
skip -= 1;
7873
new_map_counts.iter_mut().for_each(|x| *x = 0);

aoc_utils/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,16 @@ impl DirExt {
272272
}
273273

274274
/// Move one step in this direction (unbounded, may underflow)
275-
pub fn inext(&self, p: Point) -> Point {
275+
pub fn inext(&self, p: IPoint) -> IPoint {
276276
match self {
277-
DirExt::Up => Point(p.0 - 1, p.1),
278-
DirExt::UpLeft => Point(p.0 - 1, p.1 - 1),
279-
DirExt::UpRight => Point(p.0 - 1, p.1 + 1),
280-
DirExt::Down => Point(p.0 + 1, p.1),
281-
DirExt::DownLeft => Point(p.0 + 1, p.1 - 1),
282-
DirExt::DownRight => Point(p.0 + 1, p.1 + 1),
283-
DirExt::Left => Point(p.0, p.1 - 1),
284-
DirExt::Right => Point(p.0, p.1 + 1),
277+
DirExt::Up => IPoint(p.0 - 1, p.1),
278+
DirExt::UpLeft => IPoint(p.0 - 1, p.1 - 1),
279+
DirExt::UpRight => IPoint(p.0 - 1, p.1 + 1),
280+
DirExt::Down => IPoint(p.0 + 1, p.1),
281+
DirExt::DownLeft => IPoint(p.0 + 1, p.1 - 1),
282+
DirExt::DownRight => IPoint(p.0 + 1, p.1 + 1),
283+
DirExt::Left => IPoint(p.0, p.1 - 1),
284+
DirExt::Right => IPoint(p.0, p.1 + 1),
285285
}
286286
}
287287
}
@@ -528,12 +528,12 @@ mod test {
528528

529529
#[test]
530530
fn test_dir_inext() {
531-
let point = Point(2, 2);
531+
let point = IPoint(2, 2);
532532

533-
assert_eq!(Dir::Up.inext(point), Point(1, 2));
534-
assert_eq!(Dir::Down.inext(point), Point(3, 2));
535-
assert_eq!(Dir::Left.inext(point), Point(2, 1));
536-
assert_eq!(Dir::Right.inext(point), Point(2, 3));
533+
assert_eq!(Dir::Up.inext(point), IPoint(1, 2));
534+
assert_eq!(Dir::Down.inext(point), IPoint(3, 2));
535+
assert_eq!(Dir::Left.inext(point), IPoint(2, 1));
536+
assert_eq!(Dir::Right.inext(point), IPoint(2, 3));
537537
}
538538

539539
#[test]

0 commit comments

Comments
 (0)