From 218864164929b83b3eaca48fe5aa3b7768230c91 Mon Sep 17 00:00:00 2001 From: Vahor Date: Fri, 30 Jun 2023 18:59:05 +0200 Subject: [PATCH] init --- .cargo/config | 2 + .gitignore | 2 + Cargo.lock | 2011 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 19 + README.md | 0 src/fetcher.rs | 217 +++++ src/lib.rs | 5 + src/main.rs | 362 +++++++ src/problem/mod.rs | 0 src/solution/mod.rs | 237 +++++ src/util/linked_list.rs | 29 + src/util/mod.rs | 8 + src/util/point.rs | 23 + src/util/testing.rs | 1 + src/util/tree.rs | 57 ++ src/util/vec_string.rs | 5 + template.rs | 24 + 17 files changed, 3002 insertions(+) create mode 100644 .cargo/config create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/fetcher.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs create mode 100644 src/problem/mod.rs create mode 100644 src/solution/mod.rs create mode 100644 src/util/linked_list.rs create mode 100644 src/util/mod.rs create mode 100644 src/util/point.rs create mode 100644 src/util/testing.rs create mode 100644 src/util/tree.rs create mode 100644 src/util/vec_string.rs create mode 100644 template.rs diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 00000000..b05dfbcf --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[build] +rustflags = ["-A", "unused"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..96ef862d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +.idea/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..a8df0eae --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2011 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler32" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" + +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" +dependencies = [ + "backtrace-sys", + "cfg-if 0.1.10", + "libc", + "rustc-demangle", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +dependencies = [ + "byteorder", +] + +[[package]] +name = "bitflags" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" + +[[package]] +name = "bumpalo" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "either", + "iovec", +] + +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +dependencies = [ + "lazy_static", + "ppv-lite86", +] + +[[package]] +name = "cc" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cookie" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" +dependencies = [ + "time", + "url 1.7.2", +] + +[[package]] +name = "cookie_store" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" +dependencies = [ + "cookie", + "failure", + "idna 0.1.5", + "log", + "publicsuffix", + "serde", + "serde_json", + "time", + "try_from", + "url 1.7.2", +] + +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +dependencies = [ + "crossbeam-utils 0.6.6", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg 1.1.0", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +dependencies = [ + "crossbeam-utils 0.6.6", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +dependencies = [ + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.1.0", + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "curl" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06aa71e9208a54def20792d877bc663d6aae0732b9852e612c4a933177c31283" +dependencies = [ + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2", + "winapi 0.3.8", +] + +[[package]] +name = "curl-sys" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c38ca47d60b86d0cc9d42caa90a0885669c2abc9791f871c81f58cdf39e979b" +dependencies = [ + "cc", + "libc", + "libnghttp2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "winapi 0.3.8", +] + +[[package]] +name = "dtoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" + +[[package]] +name = "encoding_rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "error-chain" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" +dependencies = [ + "backtrace", + "version_check", +] + +[[package]] +name = "failure" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", + "synstructure", +] + +[[package]] +name = "flate2" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" +dependencies = [ + "cfg-if 0.1.10", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" + +[[package]] +name = "futures" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-channel-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" +dependencies = [ + "futures-core-preview", + "futures-sink-preview", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-core-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" + +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +dependencies = [ + "futures 0.1.29", + "num_cpus", +] + +[[package]] +name = "futures-executor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-executor-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" +dependencies = [ + "futures-core-preview", + "futures-util-preview", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" + +[[package]] +name = "futures-io-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" + +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2 1.0.39", + "quote 1.0.2", + "syn 1.0.96", +] + +[[package]] +name = "futures-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" +dependencies = [ + "futures-channel-preview", + "futures-core-preview", + "futures-executor-preview", + "futures-io-preview", + "futures-sink-preview", + "futures-util-preview", +] + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-sink-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "futures-util-preview" +version = "0.3.0-alpha.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" +dependencies = [ + "futures 0.1.29", + "futures-channel-preview", + "futures-core-preview", + "futures-io-preview", + "futures-sink-preview", + "memchr", + "pin-utils", + "slab", + "tokio-io", +] + +[[package]] +name = "getrandom" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +dependencies = [ + "byteorder", + "bytes", + "fnv", + "futures 0.1.29", + "http", + "indexmap", + "log", + "slab", + "string", + "tokio-io", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "http" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +dependencies = [ + "bytes", + "futures 0.1.29", + "http", + "tokio-buf", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "hyper" +version = "0.12.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c843caf6296fc1f93444735205af9ed4e109a539005abb2564ae1d6fad34c52" +dependencies = [ + "bytes", + "futures 0.1.29", + "futures-cpupool", + "h2", + "http", + "http-body", + "httparse", + "iovec", + "itoa", + "log", + "net2", + "rustc_version", + "time", + "tokio", + "tokio-buf", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" +dependencies = [ + "bytes", + "futures 0.1.29", + "hyper", + "native-tls", + "tokio-io", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" + +[[package]] +name = "iovec" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9636900aa73ffed13cdbb199f17cd955670bb300927c8d25b517dfa136b6567" +dependencies = [ + "libc", +] + +[[package]] +name = "isahc" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b77027f12e53ae59a379f7074259d32eb10867e6183388020e922832d9c3fb" +dependencies = [ + "bytes", + "crossbeam-channel", + "crossbeam-utils 0.6.6", + "curl", + "curl-sys", + "futures-io-preview", + "futures-util-preview", + "http", + "lazy_static", + "log", + "slab", + "sluice", +] + +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" + +[[package]] +name = "js-sys" +version = "0.3.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7889c7c36282151f6bf465be4700359318aef36baa951462382eae49e9577cf9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leetcode-rust" +version = "0.1.0" +dependencies = [ + "futures 0.3.4", + "rand 0.6.5", + "regex", + "reqwest", + "serde", + "serde_derive", + "serde_json", + "surf", +] + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "libnghttp2-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02254d44f4435dd79e695f2c2b83cd06a47919adea30216ceaf0c57ca0a72463" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "libz-sys" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" + +[[package]] +name = "memoffset" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "mime" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" + +[[package]] +name = "mime_guess" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "304f66c19be2afa56530fa7c39796192eef38618da8d19df725ad7c6d6b2aaae" +dependencies = [ + "adler32", +] + +[[package]] +name = "mio" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" +dependencies = [ + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "nom" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] +name = "num_cpus" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "openssl" +version = "0.10.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f372b2b53ce10fb823a337aaa674e3a7d072b957c6264d0f4ff0bd86e657449" +dependencies = [ + "bitflags", + "cfg-if 0.1.10", + "foreign-types", + "lazy_static", + "libc", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c42dcccb832556b5926bc9ae61e8775f2a61e725ab07ab3d1e7fcf8ae62c3b6" +dependencies = [ + "autocfg 0.1.6", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api", + "parking_lot_core", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi 0.3.8", +] + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "publicsuffix" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf259a81de2b2eb9850ec990ec78e6a25319715584fd7652b9b26f96fcb1510" +dependencies = [ + "error-chain", + "idna 0.2.0", + "lazy_static", + "regex", + "url 2.1.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +dependencies = [ + "proc-macro2 1.0.39", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.6", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.8", +] + +[[package]] +name = "rand" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +dependencies = [ + "getrandom", + "libc", + "rand_chacha 0.2.1", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.6", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +dependencies = [ + "c2-chacha", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[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_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.8", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.8", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.6", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "regex" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "reqwest" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b7e953e14c6f3102b7e8d1f1ee3abf5ecee80b427f5565c9389835cecae95c" +dependencies = [ + "base64", + "bytes", + "cookie", + "cookie_store", + "encoding_rs", + "flate2", + "futures 0.1.29", + "http", + "hyper", + "hyper-tls", + "log", + "mime", + "mime_guess", + "native-tls", + "serde", + "serde_json", + "serde_urlencoded 0.5.5", + "time", + "tokio", + "tokio-executor", + "tokio-io", + "tokio-threadpool", + "tokio-timer", + "url 1.7.2", + "uuid", + "winreg", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" + +[[package]] +name = "schannel" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" +dependencies = [ + "lazy_static", + "winapi 0.3.8", +] + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" + +[[package]] +name = "security-framework" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" +dependencies = [ + "core-foundation-sys", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" +dependencies = [ + "proc-macro2 1.0.39", + "quote 1.0.2", + "syn 1.0.96", +] + +[[package]] +name = "serde_json" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url 1.7.2", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url 2.1.0", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "sluice" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7d06dfb3e8743bc19e6de8a302277471d08077d68946b307280496dc5a3531" +dependencies = [ + "futures-channel-preview", + "futures-core-preview", + "futures-io-preview", +] + +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "sourcefile" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" + +[[package]] +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +dependencies = [ + "bytes", +] + +[[package]] +name = "surf" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "741a8008f8a833ef16f47df94a30754478fb2c2bf822b9c2e6f7f09203b97ace" +dependencies = [ + "futures-preview", + "http", + "isahc", + "js-sys", + "log", + "mime", + "mime_guess", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", + "url 2.1.0", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + +[[package]] +name = "syn" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +dependencies = [ + "proc-macro2 1.0.39", + "quote 1.0.2", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand 0.7.2", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +dependencies = [ + "libc", + "redox_syscall", + "winapi 0.3.8", +] + +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +dependencies = [ + "bytes", + "futures 0.1.29", + "mio", + "num_cpus", + "tokio-current-thread", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", +] + +[[package]] +name = "tokio-buf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +dependencies = [ + "bytes", + "either", + "futures 0.1.29", +] + +[[package]] +name = "tokio-current-thread" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +dependencies = [ + "futures 0.1.29", + "tokio-executor", +] + +[[package]] +name = "tokio-executor" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" +dependencies = [ + "crossbeam-utils 0.6.6", + "futures 0.1.29", +] + +[[package]] +name = "tokio-io" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" +dependencies = [ + "bytes", + "futures 0.1.29", + "log", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56391be9805bc80163151c0b9e5164ee64f4b0200962c346fea12773158f22d" +dependencies = [ + "crossbeam-utils 0.6.6", + "futures 0.1.29", + "lazy_static", + "log", + "mio", + "num_cpus", + "parking_lot", + "slab", + "tokio-executor", + "tokio-io", + "tokio-sync", +] + +[[package]] +name = "tokio-sync" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" +dependencies = [ + "fnv", + "futures 0.1.29", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" +dependencies = [ + "bytes", + "futures 0.1.29", + "iovec", + "mio", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "tokio-threadpool" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2c6a3885302581f4401c82af70d792bb9df1700e7437b0aeb4ada94d5388c" +dependencies = [ + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils 0.6.6", + "futures 0.1.29", + "lazy_static", + "log", + "num_cpus", + "slab", + "tokio-executor", +] + +[[package]] +name = "tokio-timer" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +dependencies = [ + "crossbeam-utils 0.6.6", + "futures 0.1.29", + "slab", + "tokio-executor", +] + +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" + +[[package]] +name = "try_from" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "unicase" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-ident" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + +[[package]] +name = "unicode-normalization" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna 0.1.5", + "matches", + "percent-encoding 1.0.1", +] + +[[package]] +name = "url" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" +dependencies = [ + "idna 0.2.0", + "matches", + "percent-encoding 2.1.0", +] + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" +dependencies = [ + "rand 0.6.5", +] + +[[package]] +name = "vcpkg" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" + +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" + +[[package]] +name = "want" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +dependencies = [ + "futures 0.1.29", + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" + +[[package]] +name = "wasm-bindgen" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5205e9afdf42282b192e2310a5b463a6d1c1d774e30dc3c791ac37ab42d2616c" +dependencies = [ + "cfg-if 0.1.10", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11cdb95816290b525b32587d76419facd99662a07e59d3cdb560488a819d9a45" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2 1.0.39", + "quote 1.0.2", + "syn 1.0.96", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" +dependencies = [ + "cfg-if 0.1.10", + "futures 0.1.29", + "futures-channel-preview", + "futures-util-preview", + "js-sys", + "lazy_static", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "574094772ce6921576fb6f2e3f7497b8a76273b6db092be18fc48a082de09dc3" +dependencies = [ + "quote 1.0.2", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e85031354f25eaebe78bb7db1c3d86140312a911a106b2e29f9cc440ce3e7668" +dependencies = [ + "proc-macro2 1.0.39", + "quote 1.0.2", + "syn 1.0.96", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5e7e61fc929f4c0dddb748b102ebf9f632e2b8d739f2016542b4de2965a9601" + +[[package]] +name = "wasm-bindgen-webidl" +version = "0.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef012a0d93fc0432df126a8eaf547b2dce25a8ce9212e1d3cbeef5c11157975d" +dependencies = [ + "anyhow", + "heck", + "log", + "proc-macro2 1.0.39", + "quote 1.0.2", + "syn 1.0.96", + "wasm-bindgen-backend", + "weedle", +] + +[[package]] +name = "web-sys" +version = "0.3.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf97caf6aa8c2b1dac90faf0db529d9d63c93846cca4911856f78a83cebf53b" +dependencies = [ + "anyhow", + "js-sys", + "sourcefile", + "wasm-bindgen", + "wasm-bindgen-webidl", +] + +[[package]] +name = "weedle" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" +dependencies = [ + "nom", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..9fdbe995 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "leetcode-rust" +version = "0.1.0" +authors = ["alei "] +edition = "2018" + +[dependencies] +reqwest = "0.9.8" +serde = "1.0" +serde_json = "1.0" +serde_derive = "1.0" +rand = "0.6.5" +regex = "1.3.4" +futures = { version = "0.3.3", features = ["thread-pool"] } +surf = "1.0.3" + +[lib] +doctest = false +test = true diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/src/fetcher.rs b/src/fetcher.rs new file mode 100644 index 00000000..c356dee8 --- /dev/null +++ b/src/fetcher.rs @@ -0,0 +1,217 @@ +extern crate reqwest; +extern crate serde_json; + +use serde_json::Value; +use std::fmt::{Display, Error, Formatter}; + +const PROBLEMS_URL: &str = "https://leetcode.com/api/problems/algorithms/"; +const GRAPHQL_URL: &str = "https://leetcode.com/graphql"; +const QUESTION_QUERY_STRING: &str = r#" +query questionData($titleSlug: String!) { + question(titleSlug: $titleSlug) { + content + stats + codeDefinition + sampleTestCase + metaData + } +}"#; +const QUESTION_QUERY_OPERATION: &str = "questionData"; + +pub fn get_problem(frontend_question_id: u32) -> Option { + let problems = get_problems().unwrap(); + for problem in problems.stat_status_pairs.iter() { + if problem.stat.frontend_question_id == frontend_question_id { + if problem.paid_only { + return None; + } + + let client = reqwest::Client::new(); + let resp: RawProblem = client + .post(GRAPHQL_URL) + .json(&Query::question_query( + problem.stat.question_title_slug.as_ref().unwrap(), + )) + .send() + .unwrap() + .json() + .unwrap(); + return Some(Problem { + title: problem.stat.question_title.clone().unwrap(), + title_slug: problem.stat.question_title_slug.clone().unwrap(), + code_definition: serde_json::from_str(&resp.data.question.code_definition).unwrap(), + content: resp.data.question.content, + sample_test_case: resp.data.question.sample_test_case, + difficulty: problem.difficulty.to_string(), + question_id: problem.stat.frontend_question_id, + return_type: { + let v: Value = serde_json::from_str(&resp.data.question.meta_data).unwrap(); + v["return"]["type"].to_string().replace("\"", "") + }, + }); + } + } + None +} + +pub async fn get_problem_async(problem_stat: StatWithStatus) -> Option { + if problem_stat.paid_only { + println!( + "Problem {} is paid-only", + &problem_stat.stat.frontend_question_id + ); + return None; + } + let resp = surf::post(GRAPHQL_URL).body_json(&Query::question_query( + problem_stat.stat.question_title_slug.as_ref().unwrap(), + )); + if resp.is_err() { + println!( + "Problem {} not initialized due to some error", + &problem_stat.stat.frontend_question_id + ); + return None; + } + let resp = resp.unwrap().recv_json().await; + if resp.is_err() { + println!( + "Problem {} not initialized due to some error", + &problem_stat.stat.frontend_question_id + ); + return None; + } + let resp: RawProblem = resp.unwrap(); + return Some(Problem { + title: problem_stat.stat.question_title.clone().unwrap(), + title_slug: problem_stat.stat.question_title_slug.clone().unwrap(), + code_definition: serde_json::from_str(&resp.data.question.code_definition).unwrap(), + content: resp.data.question.content, + sample_test_case: resp.data.question.sample_test_case, + difficulty: problem_stat.difficulty.to_string(), + question_id: problem_stat.stat.frontend_question_id, + return_type: { + let v: Value = serde_json::from_str(&resp.data.question.meta_data).unwrap(); + v["return"]["type"].to_string().replace("\"", "") + }, + }); +} + +pub fn get_problems() -> Option { + reqwest::get(PROBLEMS_URL).unwrap().json().unwrap() +} + +#[derive(Serialize, Deserialize)] +pub struct Problem { + pub title: String, + pub title_slug: String, + pub content: String, + #[serde(rename = "codeDefinition")] + pub code_definition: Vec, + #[serde(rename = "sampleTestCase")] + pub sample_test_case: String, + pub difficulty: String, + pub question_id: u32, + pub return_type: String, +} + +#[derive(Serialize, Deserialize)] +pub struct CodeDefinition { + pub value: String, + pub text: String, + #[serde(rename = "defaultCode")] + pub default_code: String, +} + +#[derive(Debug, Serialize, Deserialize)] +struct Query { + #[serde(rename = "operationName")] + operation_name: String, + variables: serde_json::Value, + query: String, +} + +impl Query { + fn question_query(title_slug: &str) -> Query { + Query { + operation_name: QUESTION_QUERY_OPERATION.to_owned(), + variables: json!({ "titleSlug": title_slug }), + query: QUESTION_QUERY_STRING.to_owned(), + } + } +} + +#[derive(Debug, Serialize, Deserialize)] +struct RawProblem { + data: Data, +} + +#[derive(Debug, Serialize, Deserialize)] +struct Data { + question: Question, +} + +#[derive(Debug, Serialize, Deserialize)] +struct Question { + content: String, + stats: String, + #[serde(rename = "codeDefinition")] + code_definition: String, + #[serde(rename = "sampleTestCase")] + sample_test_case: String, + #[serde(rename = "metaData")] + meta_data: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Problems { + user_name: String, + num_solved: u32, + num_total: u32, + ac_easy: u32, + ac_medium: u32, + ac_hard: u32, + pub stat_status_pairs: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct StatWithStatus { + pub stat: Stat, + difficulty: Difficulty, + paid_only: bool, + is_favor: bool, + frequency: u32, + progress: u32, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Stat { + question_id: u32, + #[serde(rename = "question__article__slug")] + question_article_slug: Option, + #[serde(rename = "question__title")] + question_title: Option, + #[serde(rename = "question__title_slug")] + question_title_slug: Option, + #[serde(rename = "question__hide")] + question_hide: bool, + total_acs: u32, + total_submitted: u32, + pub frontend_question_id: u32, + is_new_question: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +struct Difficulty { + level: u32, +} + +impl Display for Difficulty { + fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { + match self.level { + 1 => f.write_str("Easy"), + 2 => f.write_str("Medium"), + 3 => f.write_str("Hard"), + _ => f.write_str("Unknown"), + } + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..55b0298f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,5 @@ +#[macro_use] +pub mod util; + +pub mod solution; +pub mod problem; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 00000000..6fecf106 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,362 @@ +#[macro_use] +extern crate serde_derive; +#[macro_use] +extern crate serde_json; + +mod fetcher; + +use crate::fetcher::{CodeDefinition, Problem}; +use regex::Regex; +use std::env; +use std::fs; +use std::fs::File; +use std::io; +use std::io::{BufRead, Write}; +use std::path::Path; + +use futures::executor::block_on; +use futures::executor::ThreadPool; +use futures::future::join_all; +use futures::stream::StreamExt; +use futures::task::SpawnExt; +use std::sync::{Arc, Mutex}; + +/// main() helps to generate the submission template .rs +fn main() { + println!("Welcome to leetcode-rust system.\n"); + let mut initialized_ids = get_initialized_ids(); + loop { + println!( + "Please enter a frontend problem id, \n\ + or \"random\" to generate a random one, \n\ + or \"solve $i\" to move problem to solution/, \n\ + or \"all\" to initialize all problems \n" + ); + let mut is_random = false; + let mut is_solving = false; + let mut id: u32 = 0; + let mut id_arg = String::new(); + io::stdin() + .read_line(&mut id_arg) + .expect("Failed to read line"); + let id_arg = id_arg.trim(); + + let random_pattern = Regex::new(r"^random$").unwrap(); + let solving_pattern = Regex::new(r"^solve (\d+)$").unwrap(); + let all_pattern = Regex::new(r"^all$").unwrap(); + + if random_pattern.is_match(id_arg) { + println!("You select random mode."); + id = generate_random_id(&initialized_ids); + is_random = true; + println!("Generate random problem: {}", &id); + } else if solving_pattern.is_match(id_arg) { + // solve a problem + // move it from problem/ to solution/ + is_solving = true; + id = solving_pattern + .captures(id_arg) + .unwrap() + .get(1) + .unwrap() + .as_str() + .parse() + .unwrap(); + deal_solving(&id); + break; + } else if all_pattern.is_match(id_arg) { + // deal all problems + let pool = ThreadPool::new().unwrap(); + let mut tasks = vec![]; + let problems = fetcher::get_problems().unwrap(); + let mut mod_file_addon = Arc::new(Mutex::new(vec![])); + for problem_stat in problems.stat_status_pairs { + if initialized_ids.contains(&problem_stat.stat.frontend_question_id) { + continue; + } + let mod_file_addon = mod_file_addon.clone(); + tasks.push( + pool.spawn_with_handle(async move { + let problem = fetcher::get_problem_async(problem_stat).await; + if problem.is_none() { + return; + } + let problem = problem.unwrap(); + let code = problem + .code_definition + .iter() + .find(|&d| d.value == "rust".to_string()); + if code.is_none() { + println!("Problem {} has no rust version.", problem.question_id); + return; + } + // not sure this can be async + async { + mod_file_addon.lock().unwrap().push(format!( + "mod p{:04}_{};", + problem.question_id, + problem.title_slug.replace("-", "_") + )); + } + .await; + let code = code.unwrap(); + // not sure this can be async + // maybe should use async-std io + async { deal_problem(&problem, &code, false) }.await + }) + .unwrap(), + ); + } + block_on(join_all(tasks)); + let mut lib_file = fs::OpenOptions::new() + .write(true) + .append(true) + .open("./src/problem/mod.rs") + .unwrap(); + writeln!(lib_file, "{}", mod_file_addon.lock().unwrap().join("\n")); + break; + } else { + id = id_arg + .parse::() + .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); + if initialized_ids.contains(&id) { + println!("The problem you chose has been initialized in problem/"); + continue; + } + } + + let problem = fetcher::get_problem(id).unwrap_or_else(|| { + panic!( + "Error: failed to get problem #{} \ + (The problem may be paid-only or may not be exist).", + id + ) + }); + let code = problem + .code_definition + .iter() + .find(|&d| d.value == "rust".to_string()); + if code.is_none() { + println!("Problem {} has no rust version.", &id); + initialized_ids.push(problem.question_id); + continue; + } + let code = code.unwrap(); + deal_problem(&problem, &code, true); + break; + } +} + +fn generate_random_id(except_ids: &[u32]) -> u32 { + use rand::Rng; + use std::fs; + let mut rng = rand::thread_rng(); + loop { + let res: u32 = rng.gen_range(1, 1106); + if !except_ids.contains(&res) { + return res; + } + println!( + "Generate a random num ({}), but it is invalid (the problem may have been solved \ + or may have no rust version). Regenerate..", + res + ); + } +} + +fn get_initialized_ids() -> Vec { + let content = fs::read_to_string("./src/problem/mod.rs").unwrap(); + let id_pattern = Regex::new(r"p(\d{4})_").unwrap(); + id_pattern + .captures_iter(&content) + .map(|x| x.get(1).unwrap().as_str().parse().unwrap()) + .collect() +} + +fn parse_extra_use(code: &str) -> String { + let mut extra_use_line = String::new(); + // a linked-list problem + if code.contains("pub struct ListNode") { + extra_use_line.push_str("\nuse crate::util::linked_list::{ListNode, to_list};") + } + if code.contains("pub struct TreeNode") { + extra_use_line.push_str("\nuse crate::util::tree::{TreeNode, to_tree};") + } + if code.contains("pub struct Point") { + extra_use_line.push_str("\nuse crate::util::point::Point;") + } + extra_use_line +} + +fn parse_problem_link(problem: &Problem) -> String { + format!("https://leetcode.com/problems/{}/", problem.title_slug) +} + +fn parse_discuss_link(problem: &Problem) -> String { + format!( + "https://leetcode.com/problems/{}/discuss/?currentPage=1&orderBy=most_votes&query=", + problem.title_slug + ) +} + +fn insert_return_in_code(return_type: &str, code: &str) -> String { + let re = Regex::new(r"\{[ \n]+}").unwrap(); + match return_type { + "ListNode" => re + .replace(&code, "{\n Some(Box::new(ListNode::new(0)))\n }") + .to_string(), + "ListNode[]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "TreeNode" => re + .replace( + &code, + "{\n Some(Rc::new(RefCell::new(TreeNode::new(0))))\n }", + ) + .to_string(), + "boolean" => re.replace(&code, "{\n false\n }").to_string(), + "character" => re.replace(&code, "{\n '0'\n }").to_string(), + "character[][]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "double" => re.replace(&code, "{\n 0f64\n }").to_string(), + "double[]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "int[]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "integer" => re.replace(&code, "{\n 0\n }").to_string(), + "integer[]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "integer[][]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list>" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list>" => re.replace(&code, "{\n vec![]\n }").to_string(), + "list" => re.replace(&code, "{\n vec![]\n }").to_string(), + "null" => code.to_string(), + "string" => re + .replace(&code, "{\n String::new()\n }") + .to_string(), + "string[]" => re.replace(&code, "{\n vec![]\n }").to_string(), + "void" => code.to_string(), + "NestedInteger" => code.to_string(), + "Node" => code.to_string(), + _ => code.to_string(), + } +} + +fn build_desc(content: &str) -> String { + // TODO: fix this shit + content + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("

", "") + .replace("

", "") + .replace("", "") + .replace("", "") + .replace("

", "")
+        .replace("
", "") + .replace("
    ", "") + .replace("
", "") + .replace("
  • ", "") + .replace("
  • ", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", "^") + .replace(" ", " ") + .replace(">", ">") + .replace("<", "<") + .replace(""", "\"") + .replace("−", "-") + .replace("'", "'") + .replace("\n\n", "\n") + .replace("\n", "\n * ") +} + +fn deal_solving(id: &u32) { + let problem = fetcher::get_problem(*id).unwrap(); + let file_name = format!( + "p{:04}_{}", + problem.question_id, + problem.title_slug.replace("-", "_") + ); + let file_path = Path::new("./src/problem").join(format!("{}.rs", file_name)); + // check problem/ existence + if !file_path.exists() { + panic!("problem does not exist"); + } + // check solution/ no existence + let solution_name = format!( + "s{:04}_{}", + problem.question_id, + problem.title_slug.replace("-", "_") + ); + let solution_path = Path::new("./src/solution").join(format!("{}.rs", solution_name)); + if solution_path.exists() { + panic!("solution exists"); + } + // rename/move file + fs::rename(file_path, solution_path).unwrap(); + // remove from problem/mod.rs + let mod_file = "./src/problem/mod.rs"; + let target_line = format!("mod {};", file_name); + let lines: Vec = io::BufReader::new(File::open(mod_file).unwrap()) + .lines() + .map(|x| x.unwrap()) + .filter(|x| *x != target_line) + .collect(); + fs::write(mod_file, lines.join("\n")); + // insert into solution/mod.rs + let mut lib_file = fs::OpenOptions::new() + .append(true) + .open("./src/solution/mod.rs") + .unwrap(); + writeln!(lib_file, "mod {};", solution_name); +} + +fn deal_problem(problem: &Problem, code: &CodeDefinition, write_mod_file: bool) { + let file_name = format!( + "p{:04}_{}", + problem.question_id, + problem.title_slug.replace("-", "_") + ); + let file_path = Path::new("./src/problem").join(format!("{}.rs", file_name)); + if file_path.exists() { + panic!("problem already initialized"); + } + + let template = fs::read_to_string("./template.rs").unwrap(); + let source = template + .replace("__PROBLEM_TITLE__", &problem.title) + .replace("__PROBLEM_DESC__", &build_desc(&problem.content)) + .replace( + "__PROBLEM_DEFAULT_CODE__", + &insert_return_in_code(&problem.return_type, &code.default_code), + ) + .replace("__PROBLEM_ID__", &format!("{}", problem.question_id)) + .replace("__EXTRA_USE__", &parse_extra_use(&code.default_code)) + .replace("__PROBLEM_LINK__", &parse_problem_link(problem)) + .replace("__DISCUSS_LINK__", &parse_discuss_link(problem)); + + let mut file = fs::OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(&file_path) + .unwrap(); + + file.write_all(source.as_bytes()).unwrap(); + drop(file); + + if write_mod_file { + let mut lib_file = fs::OpenOptions::new() + .write(true) + .append(true) + .open("./src/problem/mod.rs") + .unwrap(); + writeln!(lib_file, "mod {};", file_name); + } +} diff --git a/src/problem/mod.rs b/src/problem/mod.rs new file mode 100644 index 00000000..e69de29b diff --git a/src/solution/mod.rs b/src/solution/mod.rs new file mode 100644 index 00000000..bc982de9 --- /dev/null +++ b/src/solution/mod.rs @@ -0,0 +1,237 @@ +mod s0001_two_sum; +mod s0002_add_two_numbers; +mod s0003_longest_substring_without_repeating_characters; +mod s0004_median_of_two_sorted_arrays; +mod s0005_longest_palindromic_substring; +mod s0006_zigzag_conversion; +mod s0007_reverse_integer; +mod s0008_string_to_integer_atoi; +mod s0009_palindrome_number; +mod s0010_regular_expression_matching; +mod s0011_container_with_most_water; +mod s0012_integer_to_roman; +mod s0013_roman_to_integer; +mod s0014_longest_common_prefix; +mod s0015_3sum; +mod s0016_3sum_closest; +mod s0017_letter_combinations_of_a_phone_number; +mod s0018_4sum; +mod s0019_remove_nth_node_from_end_of_list; +mod s0020_valid_parentheses; +mod s0021_merge_two_sorted_lists; +mod s0022_generate_parentheses; +mod s0023_merge_k_sorted_lists; +mod s0024_swap_nodes_in_pairs; +mod s0025_reverse_nodes_in_k_group; +mod s0026_remove_duplicates_from_sorted_array; +mod s0027_remove_element; +mod s0028_implement_strstr; +mod s0029_divide_two_integers; +mod s0030_substring_with_concatenation_of_all_words; +mod s0031_next_permutation; +mod s0032_longest_valid_parentheses; +mod s0033_search_in_rotated_sorted_array; +mod s0034_find_first_and_last_position_of_element_in_sorted_array; +mod s0035_search_insert_position; +mod s0036_valid_sudoku; +mod s0037_sudoku_solver; +mod s0038_count_and_say; +mod s0039_combination_sum; +mod s0040_combination_sum_ii; +mod s0041_first_missing_positive; +mod s0042_trapping_rain_water; +mod s0043_multiply_strings; +mod s0044_wildcard_matching; +mod s0045_jump_game_ii; +mod s0046_permutations; +mod s0047_permutations_ii; +mod s0048_rotate_image; +mod s0049_group_anagrams; +mod s0050_powx_n; +mod s0051_n_queens; +mod s0052_n_queens_ii; +mod s0053_maximum_subarray; +mod s0054_spiral_matrix; +mod s0055_jump_game; +mod s0056_merge_intervals; +mod s0057_insert_interval; +mod s0058_length_of_last_word; +mod s0059_spiral_matrix_ii; +mod s0060_permutation_sequence; +mod s0061_rotate_list; +mod s0062_unique_paths; +mod s0063_unique_paths_ii; +mod s0064_minimum_path_sum; +mod s0065_valid_number; +mod s0066_plus_one; +mod s0067_add_binary; +mod s0068_text_justification; +mod s0069_sqrtx; +mod s0070_climbing_stairs; +mod s0071_simplify_path; +mod s0072_edit_distance; +mod s0073_set_matrix_zeroes; +mod s0074_search_a_2d_matrix; +mod s0075_sort_colors; +mod s0076_minimum_window_substring; +mod s0077_combinations; +mod s0078_subsets; +mod s0079_word_search; +mod s0080_remove_duplicates_from_sorted_array_ii; +mod s0081_search_in_rotated_sorted_array_ii; +mod s0082_remove_duplicates_from_sorted_list_ii; +mod s0083_remove_duplicates_from_sorted_list; +mod s0084_largest_rectangle_in_histogram; +mod s0085_maximal_rectangle; +mod s0086_partition_list; +mod s0087_scramble_string; +mod s0088_merge_sorted_array; +mod s0089_gray_code; +mod s0090_subsets_ii; +mod s0091_decode_ways; +mod s0092_reverse_linked_list_ii; +mod s0093_restore_ip_addresses; +mod s0094_binary_tree_inorder_traversal; +mod s0095_unique_binary_search_trees_ii; +mod s0096_unique_binary_search_trees; +mod s0097_interleaving_string; +mod s0098_validate_binary_search_tree; +mod s0099_recover_binary_search_tree; +mod s0100_same_tree; +mod s0101_symmetric_tree; +mod s0102_binary_tree_level_order_traversal; +mod s0103_binary_tree_zigzag_level_order_traversal; +mod s0104_maximum_depth_of_binary_tree; +mod s0105_construct_binary_tree_from_preorder_and_inorder_traversal; +mod s0106_construct_binary_tree_from_inorder_and_postorder_traversal; +mod s0107_binary_tree_level_order_traversal_ii; +mod s0108_convert_sorted_array_to_binary_search_tree; +mod s0109_convert_sorted_list_to_binary_search_tree; +mod s0110_balanced_binary_tree; +mod s0111_minimum_depth_of_binary_tree; +mod s0112_path_sum; +mod s0113_path_sum_ii; +mod s0114_flatten_binary_tree_to_linked_list; +mod s0115_distinct_subsequences; +mod s0118_pascals_triangle; +mod s0119_pascals_triangle_ii; +mod s0120_triangle; +mod s0121_best_time_to_buy_and_sell_stock; +mod s0122_best_time_to_buy_and_sell_stock_ii; +mod s0123_best_time_to_buy_and_sell_stock_iii; +mod s0124_binary_tree_maximum_path_sum; +mod s0125_valid_palindrome; +mod s0126_word_ladder_ii; +mod s0127_word_ladder; +mod s0128_longest_consecutive_sequence; +mod s0129_sum_root_to_leaf_numbers; +mod s0130_surrounded_regions; +mod s0131_palindrome_partitioning; +mod s0132_palindrome_partitioning_ii; +mod s0134_gas_station; +mod s0135_candy; +mod s0136_single_number; +mod s0137_single_number_ii; +mod s0139_word_break; +mod s0140_word_break_ii; +mod s0143_reorder_list; +mod s0144_binary_tree_preorder_traversal; +mod s0145_binary_tree_postorder_traversal; +mod s0146_lru_cache; +mod s0147_insertion_sort_list; +mod s0148_sort_list; +mod s0149_max_points_on_a_line; +mod s0150_evaluate_reverse_polish_notation; +mod s0151_reverse_words_in_a_string; +mod s0152_maximum_product_subarray; +mod s0153_find_minimum_in_rotated_sorted_array; +mod s0154_find_minimum_in_rotated_sorted_array_ii; +mod s0155_min_stack; +mod s0162_find_peak_element; +mod s0164_maximum_gap; +mod s0165_compare_version_numbers; +mod s0166_fraction_to_recurring_decimal; +mod s0167_two_sum_ii_input_array_is_sorted; +mod s0168_excel_sheet_column_title; +mod s0169_majority_element; +mod s0171_excel_sheet_column_number; +mod s0172_factorial_trailing_zeroes; +mod s0173_binary_search_tree_iterator; +mod s0174_dungeon_game; +mod s0179_largest_number; +mod s0187_repeated_dna_sequences; +mod s0188_best_time_to_buy_and_sell_stock_iv; +mod s0189_rotate_array; +mod s0198_house_robber; +mod s0199_binary_tree_right_side_view; +mod s0200_number_of_islands; +mod s0201_bitwise_and_of_numbers_range; +mod s0202_happy_number; +mod s0203_remove_linked_list_elements; +mod s0204_count_primes; +mod s0205_isomorphic_strings; +mod s0206_reverse_linked_list; +mod s0207_course_schedule; +mod s0208_implement_trie_prefix_tree; +mod s0209_minimum_size_subarray_sum; +mod s0210_course_schedule_ii; +mod s0211_add_and_search_word_data_structure_design; +mod s0212_word_search_ii; +mod s0213_house_robber_ii; +mod s0214_shortest_palindrome; +mod s0215_kth_largest_element_in_an_array; +mod s0216_combination_sum_iii; +mod s0217_contains_duplicate; +mod s0218_the_skyline_problem; +mod s0219_contains_duplicate_ii; +mod s0220_contains_duplicate_iii; +mod s0221_maximal_square; +mod s0222_count_complete_tree_nodes; +mod s0223_rectangle_area; +mod s0224_basic_calculator; +mod s0225_implement_stack_using_queues; +mod s0226_invert_binary_tree; +mod s0227_basic_calculator_ii; +mod s0228_summary_ranges; +mod s0229_majority_element_ii; +mod s0230_kth_smallest_element_in_a_bst; +mod s0231_power_of_two; +mod s0232_implement_queue_using_stacks; +mod s0233_number_of_digit_one; +mod s0238_product_of_array_except_self; +mod s0239_sliding_window_maximum; +mod s0241_different_ways_to_add_parentheses; +mod s0242_valid_anagram; +mod s0257_binary_tree_paths; +mod s0258_add_digits; +mod s0260_single_number_iii; +mod s0263_ugly_number; +mod s0264_ugly_number_ii; +mod s0268_missing_number; +mod s0273_integer_to_english_words; +mod s0274_h_index; +mod s0275_h_index_ii; +mod s0279_perfect_squares; +mod s0282_expression_add_operators; +mod s0283_move_zeroes; +mod s0287_find_the_duplicate_number; +mod s0289_game_of_life; +mod s0290_word_pattern; +mod s0292_nim_game; +mod s0295_find_median_from_data_stream; +mod s0299_bulls_and_cows; +mod s0300_longest_increasing_subsequence; +mod s0301_remove_invalid_parentheses; +mod s0303_range_sum_query_immutable; +mod s0304_range_sum_query_2d_immutable; +mod s0306_additive_number; +mod s0307_range_sum_query_mutable; +mod s0309_best_time_to_buy_and_sell_stock_with_cooldown; +mod s0310_minimum_height_trees; +mod s0312_burst_balloons; +mod s0313_super_ugly_number; +mod s0509_fibonacci_number; +mod s0704_binary_search; +mod s0969_pancake_sorting; +mod s1018_binary_prefix_divisible_by_5; +mod s1046_last_stone_weight; diff --git a/src/util/linked_list.rs b/src/util/linked_list.rs new file mode 100644 index 00000000..37b18e3d --- /dev/null +++ b/src/util/linked_list.rs @@ -0,0 +1,29 @@ +#[derive(PartialEq, Eq, Debug)] +pub struct ListNode { + pub val: i32, + pub next: Option>, +} + +impl ListNode { + #[inline] + pub fn new(val: i32) -> Self { + ListNode { next: None, val } + } +} + +// helper function for test +pub fn to_list(vec: Vec) -> Option> { + let mut current = None; + for &v in vec.iter().rev() { + let mut node = ListNode::new(v); + node.next = current; + current = Some(Box::new(node)); + } + current +} + +#[macro_export] +macro_rules! linked { + ($($e:expr),*) => {to_list(vec![$($e.to_owned()), *])}; + ($($e:expr,)*) => {to_list(vec![$($e.to_owned()), *])}; +} diff --git a/src/util/mod.rs b/src/util/mod.rs new file mode 100644 index 00000000..5a3e5744 --- /dev/null +++ b/src/util/mod.rs @@ -0,0 +1,8 @@ +#[macro_use] +pub mod linked_list; +#[macro_use] +pub mod vec_string; +#[macro_use] +pub mod tree; +#[macro_use] +pub mod point; diff --git a/src/util/point.rs b/src/util/point.rs new file mode 100644 index 00000000..3af0c803 --- /dev/null +++ b/src/util/point.rs @@ -0,0 +1,23 @@ +#[derive(Debug, PartialEq, Eq)] +pub struct Point { + pub x: i32, + pub y: i32, +} + +impl Point { + #[inline] + pub fn new(x: i32, y: i32) -> Self { + Point { x, y } + } +} + +#[macro_export] +macro_rules! point { + ($($e:expr),*) => { + { + let vec = vec![$($e.to_owned()), *]; + Point::new(vec[0], vec[1]) + } + }; + ($($e:expr,)*) => (point![$($x),*]) +} diff --git a/src/util/testing.rs b/src/util/testing.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/util/testing.rs @@ -0,0 +1 @@ + diff --git a/src/util/tree.rs b/src/util/tree.rs new file mode 100644 index 00000000..dacda57d --- /dev/null +++ b/src/util/tree.rs @@ -0,0 +1,57 @@ +use std::cell::RefCell; +use std::rc::Rc; + +#[derive(Debug, PartialEq, Eq)] +pub struct TreeNode { + pub val: i32, + pub left: Option>>, + pub right: Option>>, +} + +impl TreeNode { + #[inline] + pub fn new(val: i32) -> Self { + TreeNode { + val, + left: None, + right: None, + } + } +} + +pub fn to_tree(vec: Vec>) -> Option>> { + use std::collections::VecDeque; + let head = Some(Rc::new(RefCell::new(TreeNode::new(vec[0].unwrap())))); + let mut queue = VecDeque::new(); + queue.push_back(head.as_ref().unwrap().clone()); + + for children in vec[1..].chunks(2) { + let parent = queue.pop_front().unwrap(); + if let Some(v) = children[0] { + parent.borrow_mut().left = Some(Rc::new(RefCell::new(TreeNode::new(v)))); + queue.push_back(parent.borrow().left.as_ref().unwrap().clone()); + } + if children.len() > 1 { + if let Some(v) = children[1] { + parent.borrow_mut().right = Some(Rc::new(RefCell::new(TreeNode::new(v)))); + queue.push_back(parent.borrow().right.as_ref().unwrap().clone()); + } + } + } + head +} + +#[macro_export] +macro_rules! tree { + () => { + None + }; + ($($e:expr),*) => { + { + let vec = vec![$(stringify!($e)), *]; + let vec = vec.into_iter().map(|v| v.parse::().ok()).collect::>(); + to_tree(vec) + } + }; + ($($e:expr,)*) => {(tree![$($e),*])}; +} diff --git a/src/util/vec_string.rs b/src/util/vec_string.rs new file mode 100644 index 00000000..5b07068d --- /dev/null +++ b/src/util/vec_string.rs @@ -0,0 +1,5 @@ +#[macro_export] +macro_rules! vec_string { + ($($e:expr),*) => {vec![$($e.to_owned()), *]}; + ($($e:expr,)*) => {vec![$($e.to_owned()), *]}; +} diff --git a/template.rs b/template.rs new file mode 100644 index 00000000..11411f01 --- /dev/null +++ b/template.rs @@ -0,0 +1,24 @@ +/** + * [__PROBLEM_ID__] __PROBLEM_TITLE__ + * + * __PROBLEM_DESC__ + */ +pub struct Solution {}__EXTRA_USE__ + +// problem: __PROBLEM_LINK__ +// discuss: __DISCUSS_LINK__ + +// submission codes start here + +__PROBLEM_DEFAULT_CODE__ + +// submission codes end + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test___PROBLEM_ID__() { + } +}