Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Advent of Code 2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Falk Rehse
Advent of Code 2023
Commits
cd44603c
Commit
cd44603c
authored
Dec 6, 2023
by
Falk Rehse
Browse files
Options
Downloads
Patches
Plain Diff
Day 5 with rayon
parent
2bf2223b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+87
-0
87 additions, 0 deletions
Cargo.lock
Cargo.toml
+1
-0
1 addition, 0 deletions
Cargo.toml
src/day_5_2/mod.rs
+6
-5
6 additions, 5 deletions
src/day_5_2/mod.rs
with
94 additions
and
5 deletions
Cargo.lock
+
87
−
0
View file @
cd44603c
...
...
@@ -6,6 +6,7 @@ version = 3
name = "advent-of-code-23"
version = "0.1.0"
dependencies = [
"rayon",
"regex",
]
...
...
@@ -18,12 +19,92 @@ dependencies = [
"memchr",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if",
]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "memchr"
version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "rayon"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "regex"
version = "1.10.2"
...
...
@@ -52,3 +133,9 @@ name = "regex-syntax"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
0
View file @
cd44603c
...
...
@@ -6,4 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rayon
=
"1.8.0"
regex
=
"1.10.2"
This diff is collapsed.
Click to expand it.
src/day_5_2/mod.rs
+
6
−
5
View file @
cd44603c
use
crate
::
util
::
*
;
use
rayon
::
prelude
::
*
;
pub
fn
solve_from_str
(
input
:
&
str
)
->
u64
{
let
mut
lines
=
input
.lines
();
...
...
@@ -39,11 +40,11 @@ pub fn solve_from_str(input: &str) -> u64 {
}
}
print!
(
"done building maps!"
);
print
ln
!
(
"done building maps!"
);
seeds_raw
.par_chunks
(
2
)
.map
(|
seed_data
|
{
let
mut
min_location
=
u64
::
MAX
;
for
seed_data
in
seeds_raw
.chunks
(
2
)
{
for
i
in
0
..
seed_data
[
1
]
{
let
seed
=
seed_data
[
0
]
+
i
;
...
...
@@ -59,9 +60,9 @@ pub fn solve_from_str(input: &str) -> u64 {
min_location
=
location
;
}
}
}
min_location
})
.min
()
.unwrap
()
}
fn
lookup
(
input
:
u64
,
map
:
&
Vec
<
Vec
<
u64
>>
)
->
u64
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment