Skip to content

Commit 9b89025

Browse files
committed
refactor(07/2025): simplify
1 parent c66f97b commit 9b89025

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/solutions/year2025/day07.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ impl Beam {
8383
let start = self.line.start();
8484
let end = self.line.end();
8585

86-
if start.x != other_start.x {
87-
return false;
88-
}
89-
90-
start.y <= other_start.y && end.y >= other_start.y
86+
start.x == other_start.x && (start.y..=end.y).contains(&other_start.y)
9187
}
9288

9389
fn down(&self) -> Self {
@@ -130,7 +126,7 @@ impl Display for Beam {
130126
impl PrintableOnGrid for Beam {
131127
type Cell = char;
132128

133-
fn print_on_grid(&self, grid: &mut Grid<char>) {
129+
fn print(&self, grid: &mut Grid<char>) {
134130
let mut current = self.line.start();
135131

136132
loop {

src/utils/grid.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ where
367367
where
368368
P: PrintableOnGrid<Cell = T> + ?Sized,
369369
{
370-
printable.print_on_grid(self)
370+
printable.print(self)
371371
}
372372
}
373373

@@ -413,17 +413,17 @@ where
413413

414414
pub trait PrintableOnGrid {
415415
type Cell;
416-
fn print_on_grid(&self, grid: &mut Grid<Self::Cell>);
416+
fn print(&self, grid: &mut Grid<Self::Cell>);
417417
}
418418

419419
impl<U> PrintableOnGrid for [U]
420420
where
421421
U: PrintableOnGrid,
422422
{
423423
type Cell = U::Cell;
424-
fn print_on_grid(&self, grid: &mut Grid<Self::Cell>) {
424+
fn print(&self, grid: &mut Grid<Self::Cell>) {
425425
for item in self {
426-
item.print_on_grid(grid);
426+
item.print(grid);
427427
}
428428
}
429429
}

0 commit comments

Comments
 (0)