Skip to content

Commit

Permalink
feat: bench and small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
JosefKuchar committed Dec 6, 2024
1 parent 7462f62 commit 8b93ed6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
<!--- benchmarking table --->

---
Expand Down
6 changes: 4 additions & 2 deletions src/bin/06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ pub fn part_two(input: &str) -> Option<u32> {
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] = '#';
Expand Down

0 comments on commit 8b93ed6

Please sign in to comment.