Skip to content

Commit

Permalink
Elide is_galaxy in favor of !is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffs committed Dec 11, 2023
1 parent b183166 commit 9517d3c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions 2023/day11/src/lib.rs
Original file line number Diff line number Diff line change
@@ -19,10 +19,6 @@ impl Tile {
fn is_empty(&self) -> bool {
matches!(*self, Tile::Empty)
}

fn is_galaxy(&self) -> bool {
matches!(*self, Tile::Galaxy)
}
}

pub struct Grid(Vec<Vec<Tile>>);
@@ -77,7 +73,7 @@ impl Grid {
.collect();

self.enumerate()
.filter(move |(_, t)| t.is_galaxy())
.filter(move |(_, t)| !t.is_empty())
.map(move |(Position(i, j), _)| Position(i + row_gaps[i], j + column_gaps[j]))
}

0 comments on commit 9517d3c

Please sign in to comment.