convert_to_workspace #1
44 changed files with 864 additions and 159 deletions
33
Cargo.lock
generated
33
Cargo.lock
generated
|
@ -9,9 +9,8 @@ dependencies = [
|
|||
"clap",
|
||||
"derive_more",
|
||||
"env_logger",
|
||||
"insta",
|
||||
"log",
|
||||
"regex",
|
||||
"solutions_advent_of_code_2023",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -75,9 +74,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.15"
|
||||
version = "4.5.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc"
|
||||
checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
@ -229,9 +228,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.156"
|
||||
version = "0.2.158"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a"
|
||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
|
@ -262,9 +261,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -304,6 +303,16 @@ version = "2.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e"
|
||||
|
||||
[[package]]
|
||||
name = "solutions_advent_of_code_2023"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"derive_more",
|
||||
"insta",
|
||||
"regex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
|
@ -312,9 +321,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.74"
|
||||
version = "2.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
|
||||
checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -355,9 +364,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
|||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
|
|
18
Cargo.toml
18
Cargo.toml
|
@ -1,15 +1,9 @@
|
|||
[package]
|
||||
name = "advent_of_code_2023"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["crates/cli", "crates/solutions"]
|
||||
|
||||
[dependencies]
|
||||
default-members = ["crates/cli"]
|
||||
|
||||
[workspace.dependencies]
|
||||
derive_more = { version = "1", features = ["full"] }
|
||||
regex = "1.10.6"
|
||||
clap = { version = "4.5.15", features = ["derive"] }
|
||||
env_logger = "0.11.5"
|
||||
log = "0.4.22"
|
||||
thiserror = "1.0.63"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = "1.39.0"
|
||||
|
|
439
crates/cli/Cargo.lock
generated
Normal file
439
crates/cli/Cargo.lock
generated
Normal file
|
@ -0,0 +1,439 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "advent_of_code_2023"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"derive_more",
|
||||
"env_logger",
|
||||
"insta",
|
||||
"log",
|
||||
"regex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.15.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05"
|
||||
dependencies = [
|
||||
"derive_more-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more-impl"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"humantime",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "insta"
|
||||
version = "1.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5"
|
||||
dependencies = [
|
||||
"console",
|
||||
"lazy_static",
|
||||
"linked-hash-map",
|
||||
"similar",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.156"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
14
crates/cli/Cargo.toml
Normal file
14
crates/cli/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "advent_of_code_2023"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
solutions_advent_of_code_2023 = { path = "../solutions" }
|
||||
|
||||
derive_more = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
clap = { version = "4.5.15", features = ["derive"] }
|
||||
env_logger = "0.11.5"
|
||||
log = "0.4.22"
|
3
crates/cli/src/lib.rs
Normal file
3
crates/cli/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub mod cli;
|
||||
pub mod constants;
|
||||
pub mod solutions;
|
|
@ -1,6 +1,6 @@
|
|||
pub mod day5;
|
||||
pub mod day6;
|
||||
pub mod day7;
|
||||
use solutions_advent_of_code_2023::day5;
|
||||
use solutions_advent_of_code_2023::day6;
|
||||
use solutions_advent_of_code_2023::day7;
|
||||
|
||||
pub fn create_solutions() -> Vec<Vec<fn(&str) -> String>> {
|
||||
vec![
|
15
crates/solutions/Cargo.toml
Normal file
15
crates/solutions/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "solutions_advent_of_code_2023"
|
||||
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
derive_more = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
regex = "1.10.6"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = "1.39.0"
|
|
@ -136,7 +136,7 @@ fn combine_single_to_ranges_for_seeds(single_seeds: &[UnsignedNumber]) -> Vec<Se
|
|||
mod testing {
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::solutions::day5::{
|
||||
use crate::day5::{
|
||||
combine_single_to_ranges_for_seeds, item_mapping::ItemMapping, parsing,
|
||||
seed_range::SeedRange, simulate_one_round_on_one_seed_range, solve_task_2,
|
||||
};
|
|
@ -152,7 +152,7 @@ impl FromStr for ItemMapping {
|
|||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day5::{
|
||||
use crate::day5::{
|
||||
item_mapping::{InvalidStrItemMapping, ItemMapping, MappedRange},
|
||||
seed_range::SeedRange,
|
||||
UnsignedNumber,
|
|
@ -1,9 +1,9 @@
|
|||
use crate::parsing_utils;
|
||||
use crate::utils::parsing;
|
||||
|
||||
use super::{item_mapping::ItemMapping, UnsignedNumber};
|
||||
|
||||
pub fn parse(input: &str) -> (Vec<UnsignedNumber>, Vec<Vec<ItemMapping>>) {
|
||||
let mut blocks = parsing_utils::blocks_of_lines_seperated_by_empty_lines(input);
|
||||
let mut blocks = parsing::blocks_of_lines_seperated_by_empty_lines(input);
|
||||
let seeds = {
|
||||
let first_block = blocks.next().unwrap();
|
||||
let first_line = first_block.first().unwrap();
|
|
@ -0,0 +1,172 @@
|
|||
---
|
||||
source: crates/solutions/src/day5/parsing.rs
|
||||
expression: actual
|
||||
---
|
||||
(
|
||||
[
|
||||
79,
|
||||
14,
|
||||
55,
|
||||
13,
|
||||
],
|
||||
[
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 98,
|
||||
end: 99,
|
||||
},
|
||||
target: 50,
|
||||
range: 2,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 50,
|
||||
end: 97,
|
||||
},
|
||||
target: 52,
|
||||
range: 48,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 15,
|
||||
end: 51,
|
||||
},
|
||||
target: 0,
|
||||
range: 37,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 52,
|
||||
end: 53,
|
||||
},
|
||||
target: 37,
|
||||
range: 2,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 0,
|
||||
end: 14,
|
||||
},
|
||||
target: 39,
|
||||
range: 15,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 53,
|
||||
end: 60,
|
||||
},
|
||||
target: 49,
|
||||
range: 8,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 11,
|
||||
end: 52,
|
||||
},
|
||||
target: 0,
|
||||
range: 42,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 0,
|
||||
end: 6,
|
||||
},
|
||||
target: 42,
|
||||
range: 7,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 7,
|
||||
end: 10,
|
||||
},
|
||||
target: 57,
|
||||
range: 4,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 18,
|
||||
end: 24,
|
||||
},
|
||||
target: 88,
|
||||
range: 7,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 25,
|
||||
end: 94,
|
||||
},
|
||||
target: 18,
|
||||
range: 70,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 77,
|
||||
end: 99,
|
||||
},
|
||||
target: 45,
|
||||
range: 23,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 45,
|
||||
end: 63,
|
||||
},
|
||||
target: 81,
|
||||
range: 19,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 64,
|
||||
end: 76,
|
||||
},
|
||||
target: 68,
|
||||
range: 13,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 69,
|
||||
end: 69,
|
||||
},
|
||||
target: 0,
|
||||
range: 1,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 0,
|
||||
end: 68,
|
||||
},
|
||||
target: 1,
|
||||
range: 69,
|
||||
},
|
||||
],
|
||||
[
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 56,
|
||||
end: 92,
|
||||
},
|
||||
target: 60,
|
||||
range: 37,
|
||||
},
|
||||
ItemMapping {
|
||||
source_range: SeedRange {
|
||||
start: 93,
|
||||
end: 96,
|
||||
},
|
||||
target: 56,
|
||||
range: 4,
|
||||
},
|
||||
],
|
||||
],
|
||||
)
|
|
@ -44,7 +44,7 @@ fn simuluate_reached_distance_at(
|
|||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day6::{simuluate_reached_distance_at, solve_task_2, NumericValue};
|
||||
use crate::day6::{simuluate_reached_distance_at, solve_task_2, NumericValue};
|
||||
|
||||
use super::solve_task_1;
|
||||
|
|
@ -41,7 +41,7 @@ pub fn parsing_part_2(input: &str) -> RaceRecord {
|
|||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day6::race_record::RaceRecord;
|
||||
use crate::day6::race_record::RaceRecord;
|
||||
|
||||
#[test]
|
||||
fn should_parse() {
|
|
@ -1,12 +1,12 @@
|
|||
use crate::day7::dealt_hand::DealtHand;
|
||||
use categorized_hand::{CategorizedHand, JokerOrdered};
|
||||
use crate::solutions::day7::dealt_hand::DealtHand;
|
||||
|
||||
mod categorized_hand;
|
||||
mod dealt_hand;
|
||||
mod hand_kind;
|
||||
mod hello;
|
||||
mod parsing;
|
||||
mod second_ordering;
|
||||
mod hello;
|
||||
|
||||
pub fn solve_task_1(input: &str) -> String {
|
||||
let parsed = parsing::parse_input(input);
|
||||
|
@ -22,7 +22,7 @@ pub fn solve_task_1(input: &str) -> String {
|
|||
pub fn solve_task_2(input: &str) -> String {
|
||||
const JOKER: char = 'J';
|
||||
let parsed = parsing::parse_input(input);
|
||||
let sorted_and_categorized= categorize_and_sort_with_a_joker(parsed, JOKER);
|
||||
let sorted_and_categorized = categorize_and_sort_with_a_joker(parsed, JOKER);
|
||||
let total_winning = calc_total_winning(&sorted_and_categorized);
|
||||
total_winning.to_string()
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
mod joker_ordered;
|
||||
pub use joker_ordered::JokerOrdered;
|
||||
|
||||
use crate::solutions::day7::second_ordering;
|
||||
use crate::day7::second_ordering;
|
||||
use std::usize;
|
||||
|
||||
use super::{dealt_hand::DealtHand, hand_kind::HandKind, second_ordering::StrengthOfSymbols};
|
||||
|
@ -39,8 +39,12 @@ fn hand_cmp(
|
|||
) -> std::cmp::Ordering {
|
||||
match left.kind.cmp(&right.kind) {
|
||||
std::cmp::Ordering::Equal => {
|
||||
assert_eq!(left.kind, right.kind, "If ordering is equal then the hand kind must be the same too\n\
|
||||
left kind: ({:?}) and right kind: ({:?})", left.kind, right.kind);
|
||||
assert_eq!(
|
||||
left.kind, right.kind,
|
||||
"If ordering is equal then the hand kind must be the same too\n\
|
||||
left kind: ({:?}) and right kind: ({:?})",
|
||||
left.kind, right.kind
|
||||
);
|
||||
second_ordering::compare_along_str(
|
||||
left.rest().hand(),
|
||||
right.rest().hand(),
|
||||
|
@ -48,8 +52,12 @@ fn hand_cmp(
|
|||
)
|
||||
}
|
||||
not_equal_ordering => {
|
||||
assert_ne!(left.kind, right.kind, "If ordering is not equal then the hand kind must not be the same either\n\
|
||||
left kind: ({:?}) and right kind: ({:?})", left.kind, right.kind);
|
||||
assert_ne!(
|
||||
left.kind, right.kind,
|
||||
"If ordering is not equal then the hand kind must not be the same either\n\
|
||||
left kind: ({:?}) and right kind: ({:?})",
|
||||
left.kind, right.kind
|
||||
);
|
||||
not_equal_ordering
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +86,7 @@ impl From<(DealtHand, char)> for CategorizedHand {
|
|||
mod testing {
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::solutions::day7::{categorized_hand::CategorizedHand, dealt_hand::DealtHand};
|
||||
use crate::day7::{categorized_hand::CategorizedHand, dealt_hand::DealtHand};
|
||||
|
||||
#[test]
|
||||
fn compare_correctly_by_kind_and_second_ordering() {
|
|
@ -1,6 +1,6 @@
|
|||
use derive_more::derive::Into;
|
||||
|
||||
use crate::solutions::day7::second_ordering;
|
||||
use crate::day7::second_ordering;
|
||||
|
||||
use super::{hand_cmp, CategorizedHand};
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl PartialOrd for JokerOrdered {
|
|||
mod testing {
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::solutions::day7::{
|
||||
use crate::day7::{
|
||||
categorized_hand::{CategorizedHand, JokerOrdered},
|
||||
dealt_hand::DealtHand,
|
||||
second_ordering::{self, JOKER},
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
source: crates/solutions/src/day7/categorized_hand/joker_ordered.rs
|
||||
expression: input
|
||||
---
|
||||
[
|
||||
JokerOrdered(
|
||||
CategorizedHand {
|
||||
kind: OnePair,
|
||||
rest: DealtHand {
|
||||
hand: "32T3K",
|
||||
bid: 765,
|
||||
},
|
||||
},
|
||||
),
|
||||
JokerOrdered(
|
||||
CategorizedHand {
|
||||
kind: TwoPair,
|
||||
rest: DealtHand {
|
||||
hand: "KK677",
|
||||
bid: 28,
|
||||
},
|
||||
},
|
||||
),
|
||||
JokerOrdered(
|
||||
CategorizedHand {
|
||||
kind: Four,
|
||||
rest: DealtHand {
|
||||
hand: "T55J5",
|
||||
bid: 684,
|
||||
},
|
||||
},
|
||||
),
|
||||
JokerOrdered(
|
||||
CategorizedHand {
|
||||
kind: Four,
|
||||
rest: DealtHand {
|
||||
hand: "QQQJA",
|
||||
bid: 483,
|
||||
},
|
||||
},
|
||||
),
|
||||
JokerOrdered(
|
||||
CategorizedHand {
|
||||
kind: Four,
|
||||
rest: DealtHand {
|
||||
hand: "KTJJT",
|
||||
bid: 220,
|
||||
},
|
||||
},
|
||||
),
|
||||
]
|
|
@ -58,7 +58,7 @@ impl FromStr for DealtHand {
|
|||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day7::dealt_hand::{DealtHand, InvalidStrDealtHand};
|
||||
use crate::day7::dealt_hand::{DealtHand, InvalidStrDealtHand};
|
||||
|
||||
#[test]
|
||||
fn parse_str() {
|
|
@ -1,6 +1,5 @@
|
|||
use std::{cmp::Reverse, collections::HashMap};
|
||||
|
||||
use log::warn;
|
||||
use non_zero_count::NonZeroCount;
|
||||
mod non_zero_count;
|
||||
|
||||
|
@ -121,16 +120,14 @@ fn choose_kind_from(to_choose_from: &[usize]) -> HandKind {
|
|||
}
|
||||
|
||||
calc_kind(&to_choose_from).unwrap_or_else(|| {
|
||||
warn!("Got hand ({:?}) with less than 2 cards", &to_choose_from);
|
||||
let default_value = HandKind::default();
|
||||
warn!("Default kind ({:?}) is assumed", default_value);
|
||||
default_value
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day7::{
|
||||
use crate::day7::{
|
||||
categorized_hand::CategorizedHand, dealt_hand::DealtHand, hand_kind::HandKind,
|
||||
};
|
||||
|
|
@ -6,7 +6,7 @@ pub fn parse_input(input: &str) -> Vec<DealtHand> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::solutions::day7::{dealt_hand::DealtHand, TEST_INPUT};
|
||||
use crate::day7::{dealt_hand::DealtHand, TEST_INPUT};
|
||||
|
||||
#[test]
|
||||
fn parse() {
|
|
@ -1,7 +1,5 @@
|
|||
use std::{cmp::Ordering, collections::HashMap, ops::RangeInclusive, sync::LazyLock, usize};
|
||||
|
||||
use log::warn;
|
||||
|
||||
pub const JOKER: char = 'J';
|
||||
static LETTERS_WITHOUT_JOKER: &[char] = &['T', 'Q', 'K', 'A'];
|
||||
static LETTERS: &[char] = &['T', 'J', 'Q', 'K', 'A'];
|
||||
|
@ -57,11 +55,6 @@ pub fn compare_along_str(
|
|||
}
|
||||
}
|
||||
let (left_len, right_len) = (left.len(), right.len());
|
||||
warn!(
|
||||
"Left and right seem to have no difference in strength\n\
|
||||
Now comparing via lenght ({}) ({}). By same length, lefte wins !",
|
||||
left_len, right_len
|
||||
);
|
||||
left_len.cmp(&right_len)
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
source: crates/solutions/src/day7/categorized_hand.rs
|
||||
expression: input
|
||||
---
|
||||
[
|
||||
CategorizedHand {
|
||||
kind: OnePair,
|
||||
rest: DealtHand {
|
||||
hand: "32T3K",
|
||||
bid: 765,
|
||||
},
|
||||
},
|
||||
CategorizedHand {
|
||||
kind: TwoPair,
|
||||
rest: DealtHand {
|
||||
hand: "KTJJT",
|
||||
bid: 220,
|
||||
},
|
||||
},
|
||||
CategorizedHand {
|
||||
kind: TwoPair,
|
||||
rest: DealtHand {
|
||||
hand: "KK677",
|
||||
bid: 28,
|
||||
},
|
||||
},
|
||||
CategorizedHand {
|
||||
kind: Three,
|
||||
rest: DealtHand {
|
||||
hand: "T55J5",
|
||||
bid: 684,
|
||||
},
|
||||
},
|
||||
CategorizedHand {
|
||||
kind: Three,
|
||||
rest: DealtHand {
|
||||
hand: "QQQJA",
|
||||
bid: 483,
|
||||
},
|
||||
},
|
||||
]
|
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
source: crates/solutions/src/day7/second_ordering.rs
|
||||
expression: ordered
|
||||
---
|
||||
[
|
||||
(
|
||||
'J',
|
||||
0,
|
||||
),
|
||||
(
|
||||
'0',
|
||||
1,
|
||||
),
|
||||
(
|
||||
'1',
|
||||
2,
|
||||
),
|
||||
(
|
||||
'2',
|
||||
3,
|
||||
),
|
||||
(
|
||||
'3',
|
||||
4,
|
||||
),
|
||||
(
|
||||
'4',
|
||||
5,
|
||||
),
|
||||
(
|
||||
'5',
|
||||
6,
|
||||
),
|
||||
(
|
||||
'6',
|
||||
7,
|
||||
),
|
||||
(
|
||||
'7',
|
||||
8,
|
||||
),
|
||||
(
|
||||
'8',
|
||||
9,
|
||||
),
|
||||
(
|
||||
'9',
|
||||
10,
|
||||
),
|
||||
(
|
||||
'T',
|
||||
11,
|
||||
),
|
||||
(
|
||||
'Q',
|
||||
12,
|
||||
),
|
||||
(
|
||||
'K',
|
||||
13,
|
||||
),
|
||||
(
|
||||
'A',
|
||||
14,
|
||||
),
|
||||
]
|
4
crates/solutions/src/lib.rs
Normal file
4
crates/solutions/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub mod day5;
|
||||
pub mod day6;
|
||||
pub mod day7;
|
||||
mod utils;
|
1
crates/solutions/src/utils.rs
Normal file
1
crates/solutions/src/utils.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub(crate) mod parsing;
|
|
@ -1,70 +0,0 @@
|
|||
pub trait AdventIterator: Iterator {
|
||||
fn into_chunks<const N: usize>(self) -> impl Iterator<Item = Chunk<N, Self::Item>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
in_chunks::<N, Self::Item>(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> AdventIterator for I where I: Iterator {}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Chunk<const N: usize, T> {
|
||||
Next([T; N]),
|
||||
Rest(Vec<T>),
|
||||
}
|
||||
|
||||
pub fn in_chunks<const N: usize, T>(
|
||||
mut iterator: impl Iterator<Item = T>,
|
||||
) -> impl Iterator<Item = Chunk<N, T>> {
|
||||
let mut buffer = Vec::new();
|
||||
let mut done = false;
|
||||
std::iter::from_fn(move || {
|
||||
if done {
|
||||
return None;
|
||||
}
|
||||
for _ in 0..N {
|
||||
match iterator.next() {
|
||||
Some(to_push) => buffer.push(to_push),
|
||||
None => {
|
||||
done = true;
|
||||
return if buffer.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(Chunk::Rest(std::mem::take(&mut buffer)))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
let array: [T; N] = std::mem::take(&mut buffer)
|
||||
.try_into()
|
||||
.unwrap_or_else(|_| panic!("Buffer must have the same size as the N ({})", N));
|
||||
Some(Chunk::Next(array))
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use crate::iterations::{in_chunks, Chunk};
|
||||
|
||||
#[test]
|
||||
fn should_split_chunks() {
|
||||
fn assert_case<const N: usize>(input: Vec<u32>, expected: Vec<Chunk<N, u32>>) {
|
||||
let actual: Vec<Chunk<N, u32>> = in_chunks::<N, u32>(input.into_iter()).collect();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
assert_case::<2>(vec![2], vec![Chunk::Rest(vec![2])]);
|
||||
assert_case::<2>(vec![], vec![]);
|
||||
assert_case::<2>(vec![2, 2], vec![Chunk::Next([2, 2])]);
|
||||
assert_case::<2>(
|
||||
vec![1, 2, 3],
|
||||
vec![Chunk::Next([1, 2]), Chunk::Rest(vec![3])],
|
||||
);
|
||||
assert_case::<1>(
|
||||
vec![1, 2, 3],
|
||||
vec![Chunk::Next([1]), Chunk::Next([2]), Chunk::Next([3])],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
pub mod cli;
|
||||
pub mod constants;
|
||||
pub mod iterations;
|
||||
pub mod parsing_utils;
|
||||
pub mod sequences;
|
||||
pub mod solutions;
|
|
@ -1,26 +0,0 @@
|
|||
pub fn is_sorted<T>(shoube_be_sorted: &[T]) -> bool
|
||||
where
|
||||
T: PartialOrd + Ord + Clone + PartialEq + Eq,
|
||||
{
|
||||
let mut sorted: Vec<T> = shoube_be_sorted.into_iter().cloned().collect();
|
||||
sorted.sort();
|
||||
sorted.as_slice().eq(shoube_be_sorted)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
|
||||
#[test]
|
||||
fn should_detect_if_is_sorted() {
|
||||
fn assert_case(input: &[u32], expected: bool) {
|
||||
let actual = super::is_sorted(input);
|
||||
assert_eq!(expected, actual, "Input {:#?}", input);
|
||||
}
|
||||
|
||||
assert_case(&[1, 2], true);
|
||||
assert_case(&[2, 1, 2], false);
|
||||
assert_case(&[2, 1], false);
|
||||
assert_case(&[1], true);
|
||||
assert_case(&[], true);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue