2023 day16/rust: parallelize
This commit is contained in:
parent
603321cfbe
commit
c0ed69768b
3 changed files with 6 additions and 2 deletions
|
@ -8,3 +8,4 @@ edition = "2021"
|
|||
[dependencies]
|
||||
aoc = { path = "../../../common/rust" }
|
||||
enum-map = "2.7.3"
|
||||
rayon = "1.8.0"
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::{collections::HashMap, io::stdin};
|
|||
|
||||
use aoc::vec2::{Direction, Vec2};
|
||||
use enum_map::EnumMap;
|
||||
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum Device {
|
||||
|
@ -168,9 +169,10 @@ fn main() {
|
|||
(Vec2::new(max_x - 1, y), Direction::Left),
|
||||
]
|
||||
});
|
||||
let starts: Vec<_> = hor_starts.chain(ver_starts).collect();
|
||||
|
||||
let max_energized = hor_starts
|
||||
.chain(ver_starts)
|
||||
let max_energized = starts
|
||||
.into_par_iter()
|
||||
.map(|(pos, direction)| energize_fields(PathPosition { pos, direction }, fields.clone()))
|
||||
.max()
|
||||
.unwrap();
|
||||
|
|
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -709,6 +709,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"aoc",
|
||||
"enum-map",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
Loading…
Reference in a new issue