From 8b93ed677ffff1caf420dc962e43e584dfe52cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Kucha=C5=99?= Date: Fri, 6 Dec 2024 10:22:04 +0100 Subject: [PATCH] feat: bench and small optimization --- README.md | 3 ++- src/bin/06.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a46f62b..476c2f2 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www. | [Day 3](./src/bin/03.rs) | `358.1µs` | `335.4µs` | | [Day 4](./src/bin/04.rs) | `5.8ms` | `110.4µs` | | [Day 5](./src/bin/05.rs) | `1.5ms` | `36.2ms` | +| [Day 6](./src/bin/06.rs) | `632.3µs` | `184.0ms` | -**Total: 45.01ms** +**Total: 229.64ms** --- diff --git a/src/bin/06.rs b/src/bin/06.rs index 56c6b1a..68c9c1c 100644 --- a/src/bin/06.rs +++ b/src/bin/06.rs @@ -58,8 +58,10 @@ pub fn part_two(input: &str) -> Option { visited .par_iter() .filter(|pos| { - if pos.0 == start.0 && pos.1 == start.1 { - false; + if (pos.0 == start.0 && pos.1 == start.1) + || map[pos.0 as usize][pos.1 as usize] == '#' + { + return false; } let mut map = map.clone(); map[pos.0 as usize][pos.1 as usize] = '#';