Skip to content

Commit

Permalink
simply neighbors iterator after refactor for day 16
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 16, 2023
1 parent f65d71d commit eae96b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 13](./src/bin/13.rs) | `12.3µs` | `15.9µs` |
| [Day 14](./src/bin/14.rs) | `25.0µs` | `4.5ms` |
| [Day 15](./src/bin/15.rs) | `20.4µs` | `85.9µs` |
| [Day 16](./src/bin/16.rs) | `223.2µs` | `10.9ms` |
| [Day 16](./src/bin/16.rs) | `177.4µs` | `8.2ms` |

**Total: 18.14ms**
**Total: 15.39ms**
<!--- benchmarking table --->

---
Expand Down
10 changes: 4 additions & 6 deletions src/bin/16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ impl Grid {
dir: Direction,
tile: Tile,
) -> impl Iterator<Item = (Coordinate, Direction, Tile)> + '_ {
std::iter::once(tile.next(dir))
.flatten()
.filter_map(move |dir| {
self.move_in_dir(coord, dir)
.map(|c| (c, dir, self.get_tile(c)))
})
tile.next(dir).filter_map(move |dir| {
self.move_in_dir(coord, dir)
.map(|c| (c, dir, self.get_tile(c)))
})
}

pub fn get_tile(&self, coord: Coordinate) -> Tile {
Expand Down

0 comments on commit eae96b7

Please sign in to comment.