File tree Expand file tree Collapse file tree 4 files changed +29
-66
lines changed Expand file tree Collapse file tree 4 files changed +29
-66
lines changed Original file line number Diff line number Diff line change @@ -29,5 +29,5 @@ tinyjson = "2.5.1"
2929
3030# Solution dependencies
3131itertools = " 0.13.0"
32- pariter = " 0.5.1 "
32+ rayon = " 1.10.0 "
3333regex = " 1.11.1"
Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
2727| [ Day 3] ( ./src/bin/03.rs ) | ` 561.0µs ` | ` 565.5µs ` |
2828| [ Day 4] ( ./src/bin/04.rs ) | ` 560.8µs ` | ` 161.9µs ` |
2929| [ Day 5] ( ./src/bin/05.rs ) | ` 344.6µs ` | ` 323.6µs ` |
30- | [ Day 6] ( ./src/bin/06.rs ) | ` 499.6µs ` | ` 160.3ms ` |
30+ | [ Day 6] ( ./src/bin/06.rs ) | ` 492.2µs ` | ` 118.9ms ` |
3131
32- ** Total: 164.11ms **
32+ ** Total: 122.70ms **
3333<!-- - benchmarking table --->
3434
3535---
Original file line number Diff line number Diff line change 1+ use rayon:: iter:: ParallelIterator ;
12use std:: collections:: HashSet ;
23use itertools:: Itertools ;
3- use pariter :: { scope , IteratorExt } ;
4+ use rayon :: prelude :: IntoParallelRefIterator ;
45
56advent_of_code:: solution!( 6 ) ;
67
@@ -112,8 +113,8 @@ pub fn part_two(input: &str) -> Option<u32> {
112113 map. predict_path ( ) ;
113114 let mut original_path = map. visited_pos ;
114115 original_path. remove ( & map. starting_pos ) ;
115- Some ( scope ( |scope| original_path. iter ( )
116- . parallel_filter_scoped ( scope , move |pos| {
116+ Some ( original_path. par_iter ( )
117+ . filter ( |pos| {
117118 let mut new_obstacles = map. obstacles . clone ( ) ;
118119 new_obstacles. insert ( * * pos) ;
119120 let mut map = Map {
@@ -123,7 +124,7 @@ pub fn part_two(input: &str) -> Option<u32> {
123124 } ;
124125 map. has_loop ( )
125126 } )
126- . count ( ) as u32 ) . unwrap ( ) )
127+ . count ( ) as u32 )
127128}
128129
129130#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments