diff --git a/.gitignore b/.gitignore
index 0d39227..ea8c4bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1 @@
/target
-/binaries
-/old
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..e160e61
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,6 @@
+{
+ "recommendations": [
+ "vadimcn.vscode-lldb",
+ "rust-lang.rust-analyzer"
+ ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..a91e90f
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,26 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "Debug executable 'euler'",
+ "cargo": {
+ "args": [
+ "build",
+ "--bin=euler",
+ "--package=euler"
+ ],
+ "filter": {
+ "name": "euler",
+ "kind": "bin"
+ }
+ },
+ "args": [
+ "new",
+ "30"
+ ],
+ "cwd": "${workspaceFolder}"
+ }
+ ]
+}
diff --git a/Cargo.lock b/Cargo.lock
index 6b4baf4..4cd9c39 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,26 +2,102 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "addr2line"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
- "getrandom 0.2.8",
+ "getrandom",
"once_cell",
"version_check",
]
[[package]]
-name = "aho-corasick"
-version = "0.7.20"
+name = "ahash"
+version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
+checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
+dependencies = [
+ "cfg-if",
+ "getrandom",
+ "once_cell",
+ "version_check",
+ "zerocopy",
+]
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
+[[package]]
+name = "anstream"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
+dependencies = [
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
+dependencies = [
+ "anstyle",
+ "windows-sys 0.48.0",
+]
+
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -29,10 +105,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
-name = "base64"
-version = "0.13.1"
+name = "backtrace"
+version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
+name = "base64"
+version = "0.21.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
[[package]]
name = "bitflags"
@@ -40,6 +131,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+[[package]]
+name = "bitflags"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+
[[package]]
name = "bumpalo"
version = "3.11.1"
@@ -72,46 +169,49 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
-version = "4.0.32"
+version = "4.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39"
+checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272"
dependencies = [
- "bitflags",
+ "clap_builder",
"clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1"
+dependencies = [
+ "anstream",
+ "anstyle",
"clap_lex",
- "is-terminal",
- "once_cell",
"strsim",
- "termcolor",
]
[[package]]
name = "clap_derive"
-version = "4.0.21"
+version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
+checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
dependencies = [
"heck",
- "proc-macro-error",
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.39",
]
[[package]]
name = "clap_lex"
-version = "0.3.0"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
-dependencies = [
- "os_str_bytes",
-]
+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
-name = "convert_case"
-version = "0.4.0"
+name = "colorchoice"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "core-foundation"
@@ -129,16 +229,6 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
-dependencies = [
- "cfg-if",
- "crossbeam-utils",
-]
-
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
@@ -174,11 +264,11 @@ dependencies = [
[[package]]
name = "crossterm"
-version = "0.23.2"
+version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17"
+checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
"crossterm_winapi",
"libc",
"mio",
@@ -199,29 +289,25 @@ dependencies = [
[[package]]
name = "cssparser"
-version = "0.27.2"
+version = "0.31.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a"
+checksum = "5b3df4f93e5fbbe73ec01ec8d3f68bba73107993a5b1e7519273c32db9b0d5be"
dependencies = [
"cssparser-macros",
"dtoa-short",
- "itoa 0.4.8",
- "matches",
- "phf 0.8.0",
- "proc-macro2",
- "quote",
+ "itoa",
+ "phf 0.10.1",
"smallvec",
- "syn",
]
[[package]]
name = "cssparser-macros"
-version = "0.6.0"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e"
+checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [
"quote",
- "syn",
+ "syn 2.0.39",
]
[[package]]
@@ -230,11 +316,9 @@ version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
- "convert_case",
"proc-macro2",
"quote",
- "rustc_version",
- "syn",
+ "syn 1.0.107",
]
[[package]]
@@ -273,27 +357,6 @@ dependencies = [
"cfg-if",
]
-[[package]]
-name = "errno"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
-dependencies = [
- "errno-dragonfly",
- "libc",
- "windows-sys 0.48.0",
-]
-
-[[package]]
-name = "errno-dragonfly"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
-dependencies = [
- "cc",
- "libc",
-]
-
[[package]]
name = "euler"
version = "1.0.0"
@@ -301,8 +364,10 @@ dependencies = [
"clap",
"html-escape",
"num-bigint",
+ "num-to-words",
+ "once_cell",
"owo-colors",
- "phf 0.11.1",
+ "phf 0.11.2",
"rayon",
"regex",
"requestty",
@@ -417,17 +482,6 @@ dependencies = [
"unicode-width",
]
-[[package]]
-name = "getrandom"
-version = "0.1.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi 0.9.0+wasi-snapshot-preview1",
-]
-
[[package]]
name = "getrandom"
version = "0.2.8"
@@ -436,9 +490,15 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [
"cfg-if",
"libc",
- "wasi 0.11.0+wasi-snapshot-preview1",
+ "wasi",
]
+[[package]]
+name = "gimli"
+version = "0.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
+
[[package]]
name = "h2"
version = "0.3.15"
@@ -464,7 +524,7 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
- "ahash",
+ "ahash 0.7.6",
]
[[package]]
@@ -482,12 +542,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "hermit-abi"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
-
[[package]]
name = "html-escape"
version = "0.2.13"
@@ -508,7 +562,7 @@ dependencies = [
"markup5ever",
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.107",
]
[[package]]
@@ -519,7 +573,7 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
dependencies = [
"bytes",
"fnv",
- "itoa 1.0.5",
+ "itoa",
]
[[package]]
@@ -560,9 +614,9 @@ dependencies = [
"http-body",
"httparse",
"httpdate",
- "itoa 1.0.5",
+ "itoa",
"pin-project-lite",
- "socket2",
+ "socket2 0.4.7",
"tokio",
"tower-service",
"tracing",
@@ -611,41 +665,12 @@ dependencies = [
"cfg-if",
]
-[[package]]
-name = "io-lifetimes"
-version = "1.0.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
-dependencies = [
- "hermit-abi 0.3.1",
- "libc",
- "windows-sys 0.48.0",
-]
-
[[package]]
name = "ipnet"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e"
-[[package]]
-name = "is-terminal"
-version = "0.4.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
-dependencies = [
- "hermit-abi 0.3.1",
- "io-lifetimes",
- "rustix",
- "windows-sys 0.48.0",
-]
-
-[[package]]
-name = "itoa"
-version = "0.4.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
-
[[package]]
name = "itoa"
version = "1.0.5"
@@ -669,15 +694,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.144"
+version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
-
-[[package]]
-name = "linux-raw-sys"
-version = "0.3.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
+checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "lock_api"
@@ -712,23 +731,17 @@ checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
dependencies = [
"log",
"phf 0.10.1",
- "phf_codegen 0.10.0",
+ "phf_codegen",
"string_cache",
"string_cache_codegen",
"tendril",
]
-[[package]]
-name = "matches"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
-
[[package]]
name = "memchr"
-version = "2.5.0"
+version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memoffset"
@@ -746,15 +759,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
-name = "mio"
-version = "0.8.5"
+name = "miniz_oxide"
+version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
dependencies = [
"libc",
"log",
- "wasi 0.11.0+wasi-snapshot-preview1",
- "windows-sys 0.42.0",
+ "wasi",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -782,22 +804,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
-name = "nodrop"
-version = "0.1.14"
+name = "num"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
+checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af"
+dependencies = [
+ "num-bigint",
+ "num-complex",
+ "num-integer",
+ "num-iter",
+ "num-rational",
+ "num-traits",
+]
[[package]]
name = "num-bigint"
-version = "0.4.3"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
+checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
+[[package]]
+name = "num-complex"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214"
+dependencies = [
+ "num-traits",
+]
+
[[package]]
name = "num-integer"
version = "0.1.45"
@@ -809,10 +848,43 @@ dependencies = [
]
[[package]]
-name = "num-traits"
-version = "0.2.15"
+name = "num-iter"
+version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
+checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-rational"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
+dependencies = [
+ "autocfg",
+ "num-bigint",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-to-words"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70c8c96e8d8ce07367ba8bf71271b7ab33891cc5f44063b3a109773640553c54"
+dependencies = [
+ "num",
+ "thiserror",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
@@ -823,15 +895,24 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
dependencies = [
- "hermit-abi 0.2.6",
+ "hermit-abi",
"libc",
]
[[package]]
-name = "once_cell"
-version = "1.16.0"
+name = "object"
+version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "openssl"
@@ -839,7 +920,7 @@ version = "0.10.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
"cfg-if",
"foreign-types",
"libc",
@@ -856,7 +937,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.107",
]
[[package]]
@@ -878,12 +959,6 @@ dependencies = [
"vcpkg",
]
-[[package]]
-name = "os_str_bytes"
-version = "6.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
-
[[package]]
name = "owo-colors"
version = "3.5.0"
@@ -921,42 +996,23 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "phf"
-version = "0.8.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
+checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
- "phf_macros 0.8.0",
- "phf_shared 0.8.0",
+ "phf_macros 0.10.0",
+ "phf_shared 0.10.0",
"proc-macro-hack",
]
[[package]]
name = "phf"
-version = "0.10.1"
+version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
+checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
- "phf_shared 0.10.0",
-]
-
-[[package]]
-name = "phf"
-version = "0.11.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c"
-dependencies = [
- "phf_macros 0.11.1",
- "phf_shared 0.11.1",
-]
-
-[[package]]
-name = "phf_codegen"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815"
-dependencies = [
- "phf_generator 0.8.0",
- "phf_shared 0.8.0",
+ "phf_macros 0.11.2",
+ "phf_shared 0.11.2",
]
[[package]]
@@ -969,16 +1025,6 @@ dependencies = [
"phf_shared 0.10.0",
]
-[[package]]
-name = "phf_generator"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526"
-dependencies = [
- "phf_shared 0.8.0",
- "rand 0.7.3",
-]
-
[[package]]
name = "phf_generator"
version = "0.10.0"
@@ -986,7 +1032,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared 0.10.0",
- "rand 0.8.5",
+ "rand",
]
[[package]]
@@ -995,44 +1041,35 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf"
dependencies = [
- "phf_shared 0.11.1",
- "rand 0.8.5",
+ "phf_shared 0.11.2",
+ "rand",
]
[[package]]
name = "phf_macros"
-version = "0.8.0"
+version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c"
+checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0"
dependencies = [
- "phf_generator 0.8.0",
- "phf_shared 0.8.0",
+ "phf_generator 0.10.0",
+ "phf_shared 0.10.0",
"proc-macro-hack",
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.107",
]
[[package]]
name = "phf_macros"
-version = "0.11.1"
+version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92aacdc5f16768709a569e913f7451034034178b05bdc8acda226659a3dccc66"
+checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator 0.11.1",
- "phf_shared 0.11.1",
+ "phf_shared 0.11.2",
"proc-macro2",
"quote",
- "syn",
-]
-
-[[package]]
-name = "phf_shared"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7"
-dependencies = [
- "siphasher",
+ "syn 2.0.39",
]
[[package]]
@@ -1046,18 +1083,18 @@ dependencies = [
[[package]]
name = "phf_shared"
-version = "0.11.1"
+version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676"
+checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
dependencies = [
"siphasher",
]
[[package]]
name = "pin-project-lite"
-version = "0.2.9"
+version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
@@ -1083,30 +1120,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
-[[package]]
-name = "proc-macro-error"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
-dependencies = [
- "proc-macro-error-attr",
- "proc-macro2",
- "quote",
- "syn",
- "version_check",
-]
-
-[[package]]
-name = "proc-macro-error-attr"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
-dependencies = [
- "proc-macro2",
- "quote",
- "version_check",
-]
-
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
@@ -1115,36 +1128,22 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
-version = "1.0.49"
+version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
+checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.23"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
-[[package]]
-name = "rand"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
-dependencies = [
- "getrandom 0.1.16",
- "libc",
- "rand_chacha 0.2.2",
- "rand_core 0.5.1",
- "rand_hc",
- "rand_pcg",
-]
-
[[package]]
name = "rand"
version = "0.8.5"
@@ -1152,18 +1151,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
- "rand_chacha 0.3.1",
- "rand_core 0.6.4",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
-dependencies = [
- "ppv-lite86",
- "rand_core 0.5.1",
+ "rand_chacha",
+ "rand_core",
]
[[package]]
@@ -1173,16 +1162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
- "rand_core 0.6.4",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
-dependencies = [
- "getrandom 0.1.16",
+ "rand_core",
]
[[package]]
@@ -1191,32 +1171,14 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
- "getrandom 0.2.8",
-]
-
-[[package]]
-name = "rand_hc"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
-dependencies = [
- "rand_core 0.5.1",
-]
-
-[[package]]
-name = "rand_pcg"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
-dependencies = [
- "rand_core 0.5.1",
+ "getrandom",
]
[[package]]
name = "rayon"
-version = "1.7.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
+checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
@@ -1224,14 +1186,12 @@ dependencies = [
[[package]]
name = "rayon-core"
-version = "1.11.0"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
+checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
- "crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
- "num_cpus",
]
[[package]]
@@ -1240,14 +1200,26 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
]
[[package]]
name = "regex"
-version = "1.7.0"
+version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
@@ -1256,9 +1228,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.28"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "remove_dir_all"
@@ -1271,22 +1243,24 @@ dependencies = [
[[package]]
name = "requestty"
-version = "0.4.1"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d06fb394ca73d15ad0c7bbc673459506a851a84586cd90d67d42932a280281e"
+checksum = "fa883a1f3e288e65187f653e6ba2e84fdf810fe02f4c8074f9c723d1aa26e2ae"
dependencies = [
"requestty-ui",
+ "shell-words",
"smallvec",
"tempfile",
+ "winsplit",
]
[[package]]
name = "requestty-ui"
-version = "0.4.1"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "31a4bce6f730d12e36993944036e2f93e88033d8a78734d8734fdb0043662cae"
+checksum = "7549bab39cf982b629b68e7ec191a5574e85086e95c0ebe514c02d3b42ffe225"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
"crossterm",
"once_cell",
"textwrap",
@@ -1295,9 +1269,9 @@ dependencies = [
[[package]]
name = "reqwest"
-version = "0.11.13"
+version = "0.11.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c"
+checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b"
dependencies = [
"base64",
"bytes",
@@ -1320,6 +1294,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
+ "system-configuration",
"tokio",
"tokio-native-tls",
"tower-service",
@@ -1331,27 +1306,10 @@ dependencies = [
]
[[package]]
-name = "rustc_version"
-version = "0.4.0"
+name = "rustc-demangle"
+version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
-dependencies = [
- "semver",
-]
-
-[[package]]
-name = "rustix"
-version = "0.37.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
-dependencies = [
- "bitflags",
- "errno",
- "io-lifetimes",
- "libc",
- "linux-raw-sys",
- "windows-sys 0.48.0",
-]
+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "ryu"
@@ -1377,17 +1335,17 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scraper"
-version = "0.14.0"
+version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc7cb4dae083699a22a65aa9d2699c27f525e35dffaec38b10801e958ed4cf27"
+checksum = "585480e3719b311b78a573db1c9d9c4c1f8010c2dee4cc59c2efe58ea4dbc3e1"
dependencies = [
+ "ahash 0.8.6",
"cssparser",
"ego-tree",
"getopts",
"html5ever",
- "matches",
+ "once_cell",
"selectors",
- "smallvec",
"tendril",
]
@@ -1397,7 +1355,7 @@ version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
"core-foundation",
"core-foundation-sys",
"libc",
@@ -1416,30 +1374,23 @@ dependencies = [
[[package]]
name = "selectors"
-version = "0.22.0"
+version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe"
+checksum = "4eb30575f3638fc8f6815f448d50cb1a2e255b0897985c8c59f4d37b72a07b06"
dependencies = [
- "bitflags",
+ "bitflags 2.4.1",
"cssparser",
"derive_more",
"fxhash",
"log",
- "matches",
- "phf 0.8.0",
- "phf_codegen 0.8.0",
+ "new_debug_unreachable",
+ "phf 0.10.1",
+ "phf_codegen",
"precomputed-hash",
"servo_arc",
"smallvec",
- "thin-slice",
]
-[[package]]
-name = "semver"
-version = "1.0.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
-
[[package]]
name = "serde"
version = "1.0.151"
@@ -1452,7 +1403,7 @@ version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
dependencies = [
- "itoa 1.0.5",
+ "itoa",
"ryu",
"serde",
]
@@ -1464,21 +1415,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
- "itoa 1.0.5",
+ "itoa",
"ryu",
"serde",
]
[[package]]
name = "servo_arc"
-version = "0.1.1"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432"
+checksum = "d036d71a959e00c77a63538b90a6c2390969f9772b096ea837205c6bd0491a44"
dependencies = [
- "nodrop",
"stable_deref_trait",
]
+[[package]]
+name = "shell-words"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
+
[[package]]
name = "signal-hook"
version = "0.3.14"
@@ -1546,6 +1502,16 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "socket2"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
+dependencies = [
+ "libc",
+ "windows-sys 0.48.0",
+]
+
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
@@ -1595,6 +1561,38 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "syn"
+version = "2.0.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "system-configuration"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
[[package]]
name = "tempfile"
version = "3.3.0"
@@ -1620,15 +1618,6 @@ dependencies = [
"utf-8",
]
-[[package]]
-name = "termcolor"
-version = "1.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
-dependencies = [
- "winapi-util",
-]
-
[[package]]
name = "textwrap"
version = "0.15.2"
@@ -1641,10 +1630,24 @@ dependencies = [
]
[[package]]
-name = "thin-slice"
-version = "0.1.1"
+name = "thiserror"
+version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
+checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.50"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.39",
+]
[[package]]
name = "tinyvec"
@@ -1663,33 +1666,32 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "1.23.0"
+version = "1.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46"
+checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
dependencies = [
- "autocfg",
+ "backtrace",
"bytes",
"libc",
- "memchr",
"mio",
"num_cpus",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
- "socket2",
+ "socket2 0.5.5",
"tokio-macros",
- "windows-sys 0.42.0",
+ "windows-sys 0.48.0",
]
[[package]]
name = "tokio-macros"
-version = "1.8.2"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
+checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.39",
]
[[package]]
@@ -1814,6 +1816,12 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
+[[package]]
+name = "utf8parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
+
[[package]]
name = "vcpkg"
version = "0.2.15"
@@ -1836,12 +1844,6 @@ dependencies = [
"try-lock",
]
-[[package]]
-name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
-
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@@ -1869,7 +1871,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.107",
"wasm-bindgen-shared",
]
@@ -1903,7 +1905,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.107",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -1940,15 +1942,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-[[package]]
-name = "winapi-util"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
-dependencies = [
- "winapi",
-]
-
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@@ -2123,9 +2116,36 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "winreg"
-version = "0.10.1"
+version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
+checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [
- "winapi",
+ "cfg-if",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "winsplit"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ab703352da6a72f35c39a533526393725640575bb211f61987a2748323ad956"
+
+[[package]]
+name = "zerocopy"
+version = "0.7.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f43de342578a3a14a9314a2dab1942cbfcbe5686e1f91acdc513058063eafe18"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1012d89e3acb79fad7a799ce96866cfb8098b74638465ea1b1533d35900ca90"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.39",
]
diff --git a/Cargo.toml b/Cargo.toml
index e065b62..c5a3e2a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,17 +5,19 @@ edition = "2021"
default-run = "euler"
[dependencies]
-clap = { version = "4.0.4", features = ["derive"] }
-scraper = "0.14.0"
-requestty = "0.4.1"
-reqwest = "0.11"
-tokio = { version = "1.23", features = ["full"] }
-regex = "1"
+clap = { version = "4.4.10", features = ["derive"] }
+scraper = "0.18.1"
+requestty = "0.5.0"
+reqwest = "0.11.22"
+tokio = { version = "1.34.0", features = ["full"] }
+regex = "1.10.2"
html-escape = "0.2.13"
-phf = { version = "0.11.1", features = ["macros"] }
-rayon = "1.7.0"
+phf = { version = "0.11.2", features = ["macros"] }
+rayon = "1.8.0"
owo-colors = "3.5.0"
-num-bigint = "0.4.3"
+num-bigint = "0.4.4"
+once_cell = "1.18.0"
+num-to-words = "0.1.1"
[profile.release]
opt-level = "z"
diff --git a/build b/build
deleted file mode 100755
index bf4d1c6..0000000
--- a/build
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-cargo build --release --bin "[0-9]*" -q
-cargo build --release --bin "[0-9]*" -q --target x86_64-pc-windows-gnu
-
-find ./target/release -maxdepth 1 -type f -perm 755 | while read file; do
- arr=(${file//\// })
- mv $file binaries/linux/${arr[3]} > /dev/null
-done
-
-find ./target/x86_64-pc-windows-gnu/release -maxdepth 1 -type f -perm 755 | while read file; do
- arr=(${file//\// })
- mv $file binaries/win64/${arr[4]} > /dev/null
-done
diff --git a/readme.md b/readme.md
index 2661a4a..2c82865 100644
--- a/readme.md
+++ b/readme.md
@@ -16,7 +16,7 @@ All of the solutions here are written in rust. [main.rs](src/main.rs) is the hom
## Challenge Completion
-### 22 out of 100 public challenges completed.
+### 22 out of 100 public challenges completed.
- [x] 1 - [Multiples of 3 or 5](src/bin/1.rs)
- [x] 2 - [Even Fibonacci numbers](src/bin/2.rs)
@@ -119,4 +119,4 @@ All of the solutions here are written in rust. [main.rs](src/main.rs) is the hom
- [ ] 99 - Largest exponential
- [ ] 100 - Arranged probability
-Check out Project Euler here.
\ No newline at end of file
+Check out Project Euler here.
diff --git a/src/bin/16.rs b/src/bin/16.rs
index 1edc646..cfb52e3 100644
--- a/src/bin/16.rs
+++ b/src/bin/16.rs
@@ -4,6 +4,7 @@ Problem 16 - Power digit sum
2 15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2 1000 ?
*/
+
use num_bigint::BigUint;
fn get_digits(number: usize) -> Vec {
diff --git a/src/bin/22.rs b/src/bin/22.rs
index c56ae7e..a2b20ba 100644
--- a/src/bin/22.rs
+++ b/src/bin/22.rs
@@ -5,11 +5,13 @@ Using names.txt (right click and 'Save Link/Target As...'), a 46K text file co
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 × 53 = 49714.
What is the total of all the name scores in the file?
*/
+
+use euler::RESOURCES;
use regex::Regex;
use std::fs;
fn read_names() -> Vec {
- let mut names = fs::read_to_string(euler::resources_path().join("p022_names.txt"))
+ let mut names = fs::read_to_string(RESOURCES.join("p022_names.txt"))
.unwrap()
.split(",")
.map(|name| Regex::new("\"").unwrap().replace_all(name, "").to_string())
diff --git a/src/bin/42.rs b/src/bin/42.rs
index 947f6b4..1d49d3b 100644
--- a/src/bin/42.rs
+++ b/src/bin/42.rs
@@ -7,11 +7,12 @@ By converting each letter in a word to a number corresponding to its alphabetica
Using words.txt (right click and 'Save Link/Target As...'), a 16K text file containing nearly two-thousand common English words, how many are triangle words?
*/
+use euler::RESOURCES;
use regex::Regex;
use std::fs;
fn read_words() -> Vec {
- return fs::read_to_string(euler::resources_path().join("p042_words.txt"))
+ return fs::read_to_string(RESOURCES.join("p042_words.txt"))
.unwrap()
.split(",")
.map(|name| {
diff --git a/src/bin/67.rs b/src/bin/67.rs
index 63c8fe6..eb42aaa 100644
--- a/src/bin/67.rs
+++ b/src/bin/67.rs
@@ -9,10 +9,12 @@ That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom in triangle.txt (right click and 'Save Link/Target As...'), a 15K text file containing a triangle with one-hundred rows.
NOTE: This is a much more difficult version of Problem 18 . It is not possible to try every route to solve this problem, as there are 2 99 altogether! If you could check one trillion (10 12 ) routes every second it would take over twenty billion years to check them all. There is an efficient algorithm to solve it. ;o)
*/
+
+use euler::RESOURCES;
use std::fs;
fn read_triangle() -> Vec> {
- return fs::read_to_string(euler::resources_path().join("p067_triangle.txt"))
+ return fs::read_to_string(RESOURCES.join("p067_triangle.txt"))
.unwrap()
.split("\n")
.map(|name| {
diff --git a/src/commands/new.rs b/src/commands/new.rs
index 5672e9a..8a36751 100644
--- a/src/commands/new.rs
+++ b/src/commands/new.rs
@@ -1,176 +1,107 @@
+use euler::{Problem, Result, BASE_DIR, README, SOLUTIONS};
+use num_to_words::integer_to_en_us as num_to_words;
use owo_colors::OwoColorize;
use regex::Regex;
-use scraper::{Html, Selector};
+use std::fs;
use std::io::BufReader;
use std::{
fs::{File, OpenOptions},
io::{BufRead, Write},
};
-#[tokio::main]
-pub async fn execute(problem: Option) -> Result<(), Box> {
- let code_path = euler::code_path();
- let problem_number = euler::problem_number(
- problem,
- &code_path,
- "Which problem would you like to solve?",
- );
-
- // Fetch the problem information
- let body = reqwest::get(format!("https://projecteuler.net/problem={problem_number}"))
- .await?
- .text()
- .await?;
-
- let document = Html::parse_document(body.as_str());
- let title_selector = Selector::parse("h2")?;
- let content_selector = Selector::parse(".problem_content")?;
- let html_tag_regex = Regex::new(r"<[^>]*>")?;
-
- let mut title = document
- .select(&title_selector)
- .next()
- .unwrap()
- .text()
- .collect::>()
- .join("");
-
- let mut problem = html_tag_regex
- .replace_all(
- document
- .select(&content_selector)
- .next()
- .unwrap()
- .inner_html()
- .as_str(),
- " ",
- )
- .to_string()
- .replace("$$", " ");
-
- let file_body = format!(
- "/*
-Problem {} - {}
-
-{}
-*/
-
-pub fn main() {{
- println!(\"Hello World!\");
-}}",
- problem_number,
- html_escape::decode_html_entities(&mut title).to_string(),
- html_escape::decode_html_entities(&mut problem)
- .split("\n")
- .map(|s| s.trim())
- .filter(|s| s != &"")
- .collect::>()
- .join("\n")
- );
-
- // Create the file
- let mut file = File::create(code_path.join(format!("{problem_number}.rs")))?;
- file.write(file_body.as_bytes())?;
+pub async fn execute(number: Option) -> Result<()> {
+ let problem = Problem::new(number).await?;
+ // create a file for the problem
+ let mut file = File::create(SOLUTIONS.join(format!("{}.rs", problem.number)))?;
+ file.write(problem.file_body().as_bytes())?;
drop(file);
- // Read the contents of the readme for editing
- let readme_path = euler::readme_path();
- let mut readme_file = OpenOptions::new().read(true).open(&readme_path)?;
+ // open readme
+ let mut readme_file = OpenOptions::new().read(true).open(README.clone())?;
- let mut readme_content = BufReader::new(&readme_file)
- .lines()
- .map(|s| s.unwrap())
- .collect::>();
+ let readme_content = {
+ // read
+ let mut content = BufReader::new(&readme_file)
+ .lines()
+ .map(|s| s.unwrap())
+ .collect::>()
+ .join("\n");
+ drop(readme_file);
+
+ // mark problem as done on readme
+ content = content.replace(
+ &format!("\n- [ ] {}", problem.number),
+ &format!("\n- [x] {}", problem.number),
+ );
+
+ // update completed count
+ let completion_regex = Regex::new(r"(\d+) out of")?;
+ let problem_count = fs::read_dir(SOLUTIONS.clone())?.count();
+
+ content = completion_regex
+ .replace(&content, format!("{} out of", problem_count))
+ .to_string();
+
+ content
+ };
+
+ // write the new content to the readme
+ readme_file = OpenOptions::new().write(true).open(README.clone())?;
+ readme_file.write(readme_content.as_bytes())?;
drop(readme_file);
- // Mark the problem as done on the readme
- let readme_regex = Regex::new(format!(" {problem_number} - (.*)").as_str())?;
+ // add the problem to the run command
+ let mut run_file = OpenOptions::new()
+ .read(true)
+ .open(BASE_DIR.join("src").join("commands").join("run.rs"))?;
- for i in 0..readme_content.len() {
- let line = readme_content[i].as_str();
+ let run_content = {
+ let mut content: String = BufReader::new(&run_file)
+ .lines()
+ .map(|s| s.unwrap())
+ .collect::>()
+ .join("\n");
+ drop(run_file);
- if readme_regex.is_match(line) {
- let matched = readme_regex.captures(line).unwrap();
- readme_content[i] = format!(
- "- [x] {problem_number} - [{}](src/bin/{problem_number}.rs)",
- &matched[1].trim()
- );
- }
- }
+ // add new mod
+ let mod_regex = Regex::new(r#"#\[path = ".+"\]\nmod [A-Za-z_]+;"#)?;
+ let final_mod = mod_regex.find_iter(&content).last().unwrap();
+ let word_number = num_to_words(problem.number as i64)?.replace(" ", "_");
- // Update the summary statistics on the readme
- let mut readme_string = readme_content.join("\n");
+ content.insert_str(
+ final_mod.end(),
+ &format!(
+ r#"
+#[path = "../bin/{}.rs"]
+mod {};"#,
+ problem.number, word_number
+ ),
+ );
- let completed_regex = Regex::new("([0-9]+)")?;
+ // add to match
+ let match_regex = Regex::new(r"\d+ => .+\(\),")?;
+ let final_branch = match_regex.find_iter(&content).last().unwrap();
- let new_completed =
- completed_regex.captures(readme_string.as_str()).unwrap()[1].parse::()? + 1;
+ content.insert_str(
+ final_branch.end(),
+ &format!(
+ r#"
+ {} => {}::main(),"#,
+ problem.number, word_number
+ ),
+ );
- readme_string = completed_regex
- .replace(
- readme_string.as_str(),
- format!("{new_completed}"),
- )
- .to_string();
-
- // Write the new content to the readme
- readme_file = OpenOptions::new().write(true).open(&readme_path)?;
-
- readme_file.write(readme_string.as_bytes())?;
-
- drop(readme_file);
-
- // Modify the run command
- let run_path = euler::run_path();
- let mut run_file = OpenOptions::new().read(true).open(&run_path)?;
-
- let mut run_content = BufReader::new(&run_file)
- .lines()
- .map(|s| s.unwrap())
- .collect::>();
-
- drop(run_file);
-
- // Import the problem's file
- let import_regex = Regex::new(r#"// #\[path = "\.\./bin/{x}\.rs"]"#.replace("{x}", problem_number.to_string().as_str()).as_str())?;
-
- for i in 0..run_content.len() {
- let line = run_content[i].as_str();
-
- if import_regex.is_match(line) {
- run_content[i] = line.replace("// ", "");
- run_content[i + 1] = run_content[i + 1].replace("// ", "");
-
- break;
- }
- }
-
- // Add the problem to the match statement
- let match_regex = Regex::new(
- r"// {x} =>"
- .replace("{x}", problem_number.to_string().as_str())
- .as_str(),
- )?;
-
- for i in 0..run_content.len() {
- let line = run_content[i].as_str();
-
- if match_regex.is_match(line) {
- run_content[i] = line.replace("// ", "");
- break;
- }
- }
+ content
+ };
// Write the new content to the run file
run_file = OpenOptions::new()
.write(true)
.truncate(true)
- .open(&run_path)?;
-
- run_file.write(run_content.join("\n").as_bytes())?;
-
+ .open(BASE_DIR.join("src").join("commands").join("run.rs"))?;
+ run_file.write(run_content.as_bytes())?;
drop(run_file);
// Announce completion!
diff --git a/src/commands/run.rs b/src/commands/run.rs
index 4e158ac..ef896ae 100644
--- a/src/commands/run.rs
+++ b/src/commands/run.rs
@@ -1,4 +1,6 @@
+use euler::Problem;
use owo_colors::OwoColorize;
+use std::time::Instant;
#[path = "../bin/8.rs"]
mod eight;
@@ -10,6 +12,8 @@ mod eleven;
mod fifteen;
#[path = "../bin/5.rs"]
mod five;
+#[path = "../bin/42.rs"]
+mod forty_two;
#[path = "../bin/4.rs"]
mod four;
#[path = "../bin/14.rs"]
@@ -26,6 +30,8 @@ mod seventeen;
mod six;
#[path = "../bin/16.rs"]
mod sixteen;
+#[path = "../bin/67.rs"]
+mod sixty_seven;
#[path = "../bin/10.rs"]
mod ten;
#[path = "../bin/13.rs"]
@@ -34,186 +40,29 @@ mod thirteen;
mod three;
#[path = "../bin/12.rs"]
mod twelve;
-#[path = "../bin/2.rs"]
-mod two;
-// #[path = "../bin/19.rs"]
-// mod nineteen;
-// #[path = "../bin/20.rs"]
-// mod twenty;
-// #[path = "../bin/21.rs"]
-// mod twenty_one;
-#[path = "../bin/22.rs"]
-mod twenty_two;
-// #[path = "../bin/23.rs"]
-// mod twenty_three;
-// #[path = "../bin/24.rs"]
-// mod twenty_four;
-// #[path = "../bin/25.rs"]
-// mod twenty_five;
-// #[path = "../bin/26.rs"]
-// mod twenty_six;
#[path = "../bin/27.rs"]
mod twenty_seven;
-// #[path = "../bin/28.rs"]
-// mod twenty_eight;
-// #[path = "../bin/29.rs"]
-// mod twenty_nine;
-// #[path = "../bin/30.rs"]
-// mod thirty;
-// #[path = "../bin/31.rs"]
-// mod thirty_one;
-// #[path = "../bin/32.rs"]
-// mod thirty_two;
-// #[path = "../bin/33.rs"]
-// mod thirty_three;
-// #[path = "../bin/34.rs"]
-// mod thirty_four;
-// #[path = "../bin/35.rs"]
-// mod thirty_five;
-// #[path = "../bin/36.rs"]
-// mod thirty_six;
-// #[path = "../bin/37.rs"]
-// mod thirty_seven;
-// #[path = "../bin/38.rs"]
-// mod thirty_eight;
-// #[path = "../bin/39.rs"]
-// mod thirty_nine;
-// #[path = "../bin/40.rs"]
-// mod forty;
-// #[path = "../bin/41.rs"]
-// mod forty_one;
-#[path = "../bin/42.rs"]
-mod forty_two;
-// #[path = "../bin/43.rs"]
-// mod forty_three;
-// #[path = "../bin/44.rs"]
-// mod forty_four;
-// #[path = "../bin/45.rs"]
-// mod forty_five;
-// #[path = "../bin/46.rs"]
-// mod forty_six;
-// #[path = "../bin/47.rs"]
-// mod forty_seven;
-// #[path = "../bin/48.rs"]
-// mod forty_eight;
-// #[path = "../bin/49.rs"]
-// mod forty_nine;
-// #[path = "../bin/50.rs"]
-// mod fifty;
-// #[path = "../bin/51.rs"]
-// mod fifty_one;
-// #[path = "../bin/52.rs"]
-// mod fifty_two;
-// #[path = "../bin/53.rs"]
-// mod fifty_three;
-// #[path = "../bin/54.rs"]
-// mod fifty_four;
-// #[path = "../bin/55.rs"]
-// mod fifty_five;
-// #[path = "../bin/56.rs"]
-// mod fifty_six;
-// #[path = "../bin/57.rs"]
-// mod fifty_seven;
-// #[path = "../bin/58.rs"]
-// mod fifty_eight;
-// #[path = "../bin/59.rs"]
-// mod fifty_nine;
-// #[path = "../bin/60.rs"]
-// mod sixty;
-// #[path = "../bin/61.rs"]
-// mod sixty_one;
-// #[path = "../bin/62.rs"]
-// mod sixty_two;
-// #[path = "../bin/63.rs"]
-// mod sixty_three;
-// #[path = "../bin/64.rs"]
-// mod sixty_four;
-// #[path = "../bin/65.rs"]
-// mod sixty_five;
-// #[path = "../bin/66.rs"]
-// mod sixty_six;
-#[path = "../bin/67.rs"]
-mod sixty_seven;
-// #[path = "../bin/68.rs"]
-// mod sixty_eight;
-// #[path = "../bin/69.rs"]
-// mod sixty_nine;
-// #[path = "../bin/70.rs"]
-// mod seventy;
-// #[path = "../bin/71.rs"]
-// mod seventy_one;
-// #[path = "../bin/72.rs"]
-// mod seventy_two;
-// #[path = "../bin/73.rs"]
-// mod seventy_three;
-// #[path = "../bin/74.rs"]
-// mod seventy_four;
-// #[path = "../bin/75.rs"]
-// mod seventy_five;
-// #[path = "../bin/76.rs"]
-// mod seventy_six;
-// #[path = "../bin/77.rs"]
-// mod seventy_seven;
-// #[path = "../bin/78.rs"]
-// mod seventy_eight;
-// #[path = "../bin/79.rs"]
-// mod seventy_nine;
-// #[path = "../bin/80.rs"]
-// mod eighty;
-// #[path = "../bin/81.rs"]
-// mod eighty_one;
-// #[path = "../bin/82.rs"]
-// mod eighty_two;
-// #[path = "../bin/83.rs"]
-// mod eighty_three;
-// #[path = "../bin/84.rs"]
-// mod eighty_four;
-// #[path = "../bin/85.rs"]
-// mod eighty_five;
-// #[path = "../bin/86.rs"]
-// mod eighty_six;
-// #[path = "../bin/87.rs"]
-// mod eighty_seven;
-// #[path = "../bin/88.rs"]
-// mod eighty_eight;
-// #[path = "../bin/89.rs"]
-// mod eighty_nine;
-// #[path = "../bin/90.rs"]
-// mod ninety;
-// #[path = "../bin/91.rs"]
-// mod ninety_one;
-// #[path = "../bin/92.rs"]
-// mod ninety_two;
-// #[path = "../bin/93.rs"]
-// mod ninety_three;
-// #[path = "../bin/94.rs"]
-// mod ninety_four;
-// #[path = "../bin/95.rs"]
-// mod ninety_five;
-// #[path = "../bin/96.rs"]
-// mod ninety_six;
-// #[path = "../bin/97.rs"]
-// mod ninety_seven;
-// #[path = "../bin/98.rs"]
-// mod ninety_eight;
-// #[path = "../bin/99.rs"]
-// mod ninety_nine;
-// #[path = "../bin/100.rs"]
-// mod one_hundred;
+#[path = "../bin/22.rs"]
+mod twenty_two;
+#[path = "../bin/2.rs"]
+mod two;
-#[tokio::main]
pub async fn execute(
problem: Option,
benchmark: bool,
) -> Result<(), Box> {
- let code_path = euler::code_path();
- let problem_number =
- euler::problem_number(problem, &code_path, "Which problem would you like to run?");
+ let problem = problem
+ .unwrap_or_else(|| Problem::prompt_number("Please select a problem:", true).unwrap());
+ let mut exists = true; // assume it exists
- let start = std::time::Instant::now();
- let mut exists = true;
+ let start = if benchmark {
+ Some(Instant::now())
+ } else {
+ None
+ };
- match problem_number {
+ // execute the solution
+ match problem {
1 => one::main(),
2 => two::main(),
3 => three::main(),
@@ -232,105 +81,28 @@ pub async fn execute(
16 => sixteen::main(),
17 => seventeen::main(),
18 => eighteen::main(),
- // 19 => nineteen::main(),
- // 20 => twenty::main(),
- // 21 => twenty_one::main(),
22 => twenty_two::main(),
- // 23 => twenty_three::main(),
- // 24 => twenty_four::main(),
- // 25 => twenty_five::main(),
- // 26 => twenty_six::main(),
27 => twenty_seven::main(),
- // 28 => twenty_eight::main(),
- // 29 => twenty_nine::main(),
- // 30 => thirty::main(),
- // 31 => thirty_one::main(),
- // 32 => thirty_two::main(),
- // 33 => thirty_three::main(),
- // 34 => thirty_four::main(),
- // 35 => thirty_five::main(),
- // 36 => thirty_six::main(),
- // 37 => thirty_seven::main(),
- // 38 => thirty_eight::main(),
- // 39 => thirty_nine::main(),
- // 40 => forty::main(),
- // 41 => forty_one::main(),
- // 42 => forty_two::main(),
- // 43 => forty_three::main(),
- // 44 => forty_four::main(),
- // 45 => forty_five::main(),
- // 46 => forty_six::main(),
- // 47 => forty_seven::main(),
- // 48 => forty_eight::main(),
- // 49 => forty_nine::main(),
- // 50 => fifty::main(),
- // 51 => fifty_one::main(),
- // 52 => fifty_two::main(),
- // 53 => fifty_three::main(),
- // 54 => fifty_four::main(),
- // 55 => fifty_five::main(),
- // 56 => fifty_six::main(),
- // 57 => fifty_seven::main(),
- // 58 => fifty_eight::main(),
- // 59 => fifty_nine::main(),
- // 60 => sixty::main(),
- // 61 => sixty_one::main(),
- // 62 => sixty_two::main(),
- // 63 => sixty_three::main(),
- // 64 => sixty_four::main(),
- // 65 => sixty_five::main(),
- // 66 => sixty_six::main(),
67 => sixty_seven::main(),
- // 68 => sixty_eight::main(),
- // 69 => sixty_nine::main(),
- // 70 => seventy::main(),
- // 71 => seventy_one::main(),
- // 72 => seventy_two::main(),
- // 73 => seventy_three::main(),
- // 74 => seventy_four::main(),
- // 75 => seventy_five::main(),
- // 76 => seventy_six::main(),
- // 77 => seventy_seven::main(),
- // 78 => seventy_eight::main(),
- // 79 => seventy_nine::main(),
- // 80 => eighty::main(),
- // 81 => eighty_one::main(),
- // 82 => eighty_two::main(),
- // 83 => eighty_three::main(),
- // 84 => eighty_four::main(),
- // 85 => eighty_five::main(),
- // 86 => eighty_six::main(),
- // 87 => eighty_seven::main(),
- // 88 => eighty_eight::main(),
- // 89 => eighty_nine::main(),
- // 90 => ninety::main(),
- // 91 => ninety_one::main(),
- // 92 => ninety_two::main(),
- // 93 => ninety_three::main(),
- // 94 => ninety_four::main(),
- // 95 => ninety_five::main(),
- // 96 => ninety_six::main(),
- // 97 => ninety_seven::main(),
- // 98 => ninety_eight::main(),
- // 99 => ninety_nine::main(),
- // 100 => one_hundred::main(),
_ => {
exists = false;
println!(
- "{} {} {}",
- "Problem".red().bold(),
- problem_number.red().bold(),
- "is not in this repository!".red().bold()
+ "{}",
+ format!("Problem #{problem} is yet to be solved!")
+ .red()
+ .bold()
)
}
}
- let duration = start.elapsed();
-
+ // if the script exists, print the time elapsed
if benchmark && exists {
+ let duration = start.unwrap().elapsed();
+
println!(
- "Time elapsed when executing problem {} is: {:?}",
- problem_number, duration
+ "
+Time elapsed when executing problem {} is: {:?}",
+ problem, duration
);
}
diff --git a/src/lib.rs b/src/lib.rs
index 73760a9..4e1e9bb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,65 +1,16 @@
-use std::path::{Path, PathBuf};
+mod problem;
-fn fetch_dir() -> &'static Path {
- return Path::new(env!("CARGO_MANIFEST_DIR"));
-}
+use once_cell::sync::Lazy;
+pub use problem::Problem;
+use std::path::PathBuf;
-pub fn code_path() -> PathBuf {
- return fetch_dir().join("src").join("bin");
-}
+pub type Result = std::result::Result>;
-pub fn resources_path() -> PathBuf {
- return fetch_dir().join("resources");
-}
+// paths
+pub const BASE_DIR: Lazy = Lazy::new(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")));
+pub const SOLUTIONS: Lazy = Lazy::new(|| BASE_DIR.join("src").join("bin"));
+pub const RESOURCES: Lazy = Lazy::new(|| BASE_DIR.join("resources"));
+pub const README: Lazy = Lazy::new(|| BASE_DIR.join("readme.md"));
-pub fn readme_path() -> PathBuf {
- return fetch_dir().join("readme.md");
-}
-
-pub fn run_path() -> PathBuf {
- return fetch_dir().join("src").join("commands").join("run.rs");
-}
-
-pub fn problem_number(problem: Option, code_path: &PathBuf, prompt: &str) -> u8 {
- if let Some(n) = problem {
- return n;
- } else {
- return requestty::prompt_one(
- requestty::Question::int("problemNumber")
- .message(prompt)
- .validate(|n, _| {
- // All numbers must be positive
- let mut pass = false;
-
- // Ensure that the problem has not already got a file associated with it
- let files = std::fs::read_dir(code_path).unwrap();
-
- for file in files {
- let file_number = file
- .unwrap()
- .file_name()
- .to_str()
- .unwrap()
- .split('.')
- .collect::>()[0]
- .parse::()
- .unwrap();
-
- if n == file_number {
- pass = true;
- }
- }
-
- if pass {
- Ok(())
- } else {
- Err("Please ensure that your input is valid!".to_owned())
- }
- })
- .build(),
- )
- .unwrap()
- .as_int()
- .unwrap() as u8;
- }
-}
+// panic channel
+pub static mut SILENT_PANIC: bool = false;
diff --git a/src/main.rs b/src/main.rs
index 29c6790..13c264c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,12 @@
#![allow(dead_code)]
-use clap::{Args, Parser, Subcommand};
mod commands;
+use std::panic;
+
+use clap::{Args, Parser, Subcommand};
+use euler::{Result, SILENT_PANIC};
+
#[derive(Parser)]
#[clap(about, author, version)]
struct Value {
@@ -32,11 +36,22 @@ enum Commands {
Run(RunArgs),
}
-pub fn main() -> Result<(), Box> {
+#[tokio::main]
+pub async fn main() -> Result<()> {
+ panic::set_hook(Box::new(move |panic_info| {
+ if unsafe { SILENT_PANIC } {
+ std::process::exit(0);
+ } else {
+ println!("{}", panic_info.to_string());
+ }
+ }));
+
let value = Value::parse();
match value.command {
- Commands::New(NewArgs { problem }) => commands::new::execute(problem),
- Commands::Run(RunArgs { problem, benchmark }) => commands::run::execute(problem, benchmark),
+ Commands::New(NewArgs { problem }) => commands::new::execute(problem).await,
+ Commands::Run(RunArgs { problem, benchmark }) => {
+ commands::run::execute(problem, benchmark).await
+ }
}
}
diff --git a/src/problem.rs b/src/problem.rs
new file mode 100644
index 0000000..0d8dfc3
--- /dev/null
+++ b/src/problem.rs
@@ -0,0 +1,126 @@
+use crate::{Result, SILENT_PANIC, SOLUTIONS};
+use regex::Regex;
+use scraper::{Html, Selector};
+
+pub struct Problem {
+ pub number: u8,
+ title: String,
+ content: String,
+}
+
+impl Problem {
+ pub fn prompt_number(prompt: &str, want_solved: bool) -> Result {
+ unsafe {
+ SILENT_PANIC = true;
+ }
+
+ let number = requestty::prompt_one(
+ requestty::Question::int("problemNumber")
+ .message(prompt)
+ .validate(|n, _| {
+ // ensure the number is in bound
+ if n <= 0 {
+ Err("Please enter a number greater than 0".to_string())
+ } else if n > 100 {
+ Err("Please enter a number less than or equal to 100".to_string())
+ }
+ // ensure that the problem has not already got a file associated with it
+ else {
+ let has_file = std::fs::read_dir(SOLUTIONS.clone()).unwrap().any(|x| {
+ x.unwrap()
+ .file_name()
+ .to_str()
+ .unwrap()
+ .split(".")
+ .next()
+ .unwrap()
+ .parse::()
+ .unwrap()
+ == n
+ });
+
+ if !want_solved && has_file {
+ Err("This problem has already been solved".to_string())
+ } else if want_solved && !has_file {
+ Err("This problem has not been solved yet".to_string())
+ } else {
+ Ok(())
+ }
+ }
+ })
+ .build(),
+ )?
+ .as_int()
+ .unwrap() as u8;
+
+ unsafe {
+ SILENT_PANIC = false;
+ }
+
+ Ok(number)
+ }
+
+ pub async fn new(number: Option) -> Result {
+ let number = number
+ .unwrap_or_else(|| Self::prompt_number("Please select a problem:", false).unwrap());
+
+ let body = reqwest::get(format!("https://projecteuler.net/problem={number}"))
+ .await?
+ .text()
+ .await?;
+
+ let document = Html::parse_document(body.as_str());
+ let title_selector = Selector::parse("h2")?;
+ let content_selector = Selector::parse(".problem_content")?;
+ let html_tag_regex = Regex::new(r"<[^>]*>")?;
+
+ let title = document
+ .select(&title_selector)
+ .next()
+ .unwrap()
+ .text()
+ .collect::>()
+ .join("");
+
+ let problem = html_tag_regex
+ .replace_all(
+ document
+ .select(&content_selector)
+ .next()
+ .unwrap()
+ .inner_html()
+ .as_str(),
+ " ",
+ )
+ .to_string()
+ .replace("$$", " ");
+
+ Ok(Self {
+ number,
+ title: title.trim().to_string(),
+ content: problem.trim().to_string(),
+ })
+ }
+
+ pub fn file_body(&self) -> String {
+ format!(
+ "/*
+ Problem {} - {}
+
+ {}
+ */
+
+ pub fn main() {{
+ println!(\"Hello World!\");
+ }}",
+ self.number,
+ html_escape::decode_html_entities(&self.title).to_string(),
+ html_escape::decode_html_entities(&self.content)
+ .split("\n")
+ .map(|s| s.trim())
+ .filter(|s| s != &"")
+ .collect::>()
+ .join("\n")
+ )
+ }
+}