From eae96b74591c3f1d03980939f6ae3ff8d86f85ca Mon Sep 17 00:00:00 2001 From: Kevin Caffrey Date: Sat, 16 Dec 2023 14:30:36 -0500 Subject: [PATCH] simply neighbors iterator after refactor for day 16 --- README.md | 4 ++-- src/bin/16.rs | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fa1b3dc..6cc065a 100644 --- a/README.md +++ b/README.md @@ -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** --- diff --git a/src/bin/16.rs b/src/bin/16.rs index 134199d..e2bf85c 100644 --- a/src/bin/16.rs +++ b/src/bin/16.rs @@ -84,12 +84,10 @@ impl Grid { dir: Direction, tile: Tile, ) -> impl Iterator + '_ { - 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 {