From 739eb7ae2a6cc86e5e9d2f1c9d43758c85b13a5c Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Tue, 3 Sep 2024 17:49:38 -0500 Subject: [PATCH] Move problems into subfolder to reduce import repetition --- docs/conf.py | 2 +- docs/src/python/lib/fibonacci.rst | 2 +- docs/src/rust/p0001.rst | 6 +-- docs/src/rust/p0002.rst | 6 +-- docs/src/rust/p0003.rst | 6 +-- docs/src/rust/p0004.rst | 6 +-- docs/src/rust/p0005.rst | 6 +-- docs/src/rust/p0006.rst | 6 +-- docs/src/rust/p0007.rst | 6 +-- docs/src/rust/p0008.rst | 6 +-- docs/src/rust/p0009.rst | 6 +-- docs/src/rust/p0010.rst | 6 +-- docs/src/rust/p0011.rst | 6 +-- docs/src/rust/p0012.rst | 6 +-- docs/src/rust/p0013.rst | 6 +-- docs/src/rust/p0014.rst | 6 +-- docs/src/rust/p0015.rst | 6 +-- docs/src/rust/p0016.rst | 6 +-- docs/src/rust/p0017.rst | 6 +-- docs/src/rust/p0018.rst | 6 +-- docs/src/rust/p0019.rst | 6 +-- docs/src/rust/p0020.rst | 6 +-- docs/src/rust/p0021.rst | 6 +-- docs/src/rust/p0022.rst | 6 +-- docs/src/rust/p0023.rst | 6 +-- docs/src/rust/p0024.rst | 6 +-- docs/src/rust/p0025.rst | 6 +-- docs/src/rust/p0027.rst | 6 +-- docs/src/rust/p0034.rst | 6 +-- docs/src/rust/p0035.rst | 6 +-- docs/src/rust/p0036.rst | 6 +-- docs/src/rust/p0037.rst | 6 +-- docs/src/rust/p0041.rst | 6 +-- docs/src/rust/p0044.rst | 6 +-- docs/src/rust/p0045.rst | 6 +-- docs/src/rust/p0053.rst | 6 +-- docs/src/rust/p0059.rst | 6 +-- docs/src/rust/p0067.rst | 6 +-- docs/src/rust/p0069.rst | 6 +-- docs/src/rust/p0076.rst | 6 +-- docs/src/rust/p0077.rst | 6 +-- docs/src/rust/p0087.rst | 6 +-- docs/src/rust/p0187.rst | 6 +-- docs/src/rust/p0357.rst | 6 +-- docs/src/rust/p0836.rst | 6 +-- rust/Cargo.toml | 2 +- rust/README.rst | 85 +++++++++++++++---------------- rust/src/include/problems.rs | 69 +++++++++---------------- rust/src/lib.rs | 51 +++++-------------- rust/src/problems/mod.rs | 22 ++++++++ rust/src/{ => problems}/p0001.rs | 0 rust/src/{ => problems}/p0002.rs | 0 rust/src/{ => problems}/p0003.rs | 0 rust/src/{ => problems}/p0004.rs | 0 rust/src/{ => problems}/p0005.rs | 0 rust/src/{ => problems}/p0006.rs | 0 rust/src/{ => problems}/p0007.rs | 0 rust/src/{ => problems}/p0008.rs | 0 rust/src/{ => problems}/p0009.rs | 0 rust/src/{ => problems}/p0010.rs | 0 rust/src/{ => problems}/p0011.rs | 0 rust/src/{ => problems}/p0012.rs | 0 rust/src/{ => problems}/p0013.rs | 0 rust/src/{ => problems}/p0014.rs | 0 rust/src/{ => problems}/p0015.rs | 0 rust/src/{ => problems}/p0016.rs | 0 rust/src/{ => problems}/p0017.rs | 0 rust/src/{ => problems}/p0018.rs | 0 rust/src/{ => problems}/p0019.rs | 0 rust/src/{ => problems}/p0020.rs | 0 rust/src/{ => problems}/p0021.rs | 0 rust/src/{ => problems}/p0022.rs | 0 rust/src/{ => problems}/p0023.rs | 0 rust/src/{ => problems}/p0024.rs | 0 rust/src/{ => problems}/p0025.rs | 0 rust/src/{ => problems}/p0027.rs | 0 rust/src/{ => problems}/p0034.rs | 0 rust/src/{ => problems}/p0035.rs | 0 rust/src/{ => problems}/p0036.rs | 0 rust/src/{ => problems}/p0037.rs | 0 rust/src/{ => problems}/p0041.rs | 0 rust/src/{ => problems}/p0044.rs | 0 rust/src/{ => problems}/p0045.rs | 0 rust/src/{ => problems}/p0053.rs | 0 rust/src/{ => problems}/p0059.rs | 4 +- rust/src/{ => problems}/p0067.rs | 0 rust/src/{ => problems}/p0069.rs | 0 rust/src/{ => problems}/p0076.rs | 0 rust/src/{ => problems}/p0077.rs | 2 +- rust/src/{ => problems}/p0087.rs | 0 rust/src/{ => problems}/p0187.rs | 0 rust/src/{ => problems}/p0357.rs | 0 rust/src/{ => problems}/p0836.rs | 0 93 files changed, 238 insertions(+), 259 deletions(-) create mode 100644 rust/src/problems/mod.rs rename rust/src/{ => problems}/p0001.rs (100%) rename rust/src/{ => problems}/p0002.rs (100%) rename rust/src/{ => problems}/p0003.rs (100%) rename rust/src/{ => problems}/p0004.rs (100%) rename rust/src/{ => problems}/p0005.rs (100%) rename rust/src/{ => problems}/p0006.rs (100%) rename rust/src/{ => problems}/p0007.rs (100%) rename rust/src/{ => problems}/p0008.rs (100%) rename rust/src/{ => problems}/p0009.rs (100%) rename rust/src/{ => problems}/p0010.rs (100%) rename rust/src/{ => problems}/p0011.rs (100%) rename rust/src/{ => problems}/p0012.rs (100%) rename rust/src/{ => problems}/p0013.rs (100%) rename rust/src/{ => problems}/p0014.rs (100%) rename rust/src/{ => problems}/p0015.rs (100%) rename rust/src/{ => problems}/p0016.rs (100%) rename rust/src/{ => problems}/p0017.rs (100%) rename rust/src/{ => problems}/p0018.rs (100%) rename rust/src/{ => problems}/p0019.rs (100%) rename rust/src/{ => problems}/p0020.rs (100%) rename rust/src/{ => problems}/p0021.rs (100%) rename rust/src/{ => problems}/p0022.rs (100%) rename rust/src/{ => problems}/p0023.rs (100%) rename rust/src/{ => problems}/p0024.rs (100%) rename rust/src/{ => problems}/p0025.rs (100%) rename rust/src/{ => problems}/p0027.rs (100%) rename rust/src/{ => problems}/p0034.rs (100%) rename rust/src/{ => problems}/p0035.rs (100%) rename rust/src/{ => problems}/p0036.rs (100%) rename rust/src/{ => problems}/p0037.rs (100%) rename rust/src/{ => problems}/p0041.rs (100%) rename rust/src/{ => problems}/p0044.rs (100%) rename rust/src/{ => problems}/p0045.rs (100%) rename rust/src/{ => problems}/p0053.rs (100%) rename rust/src/{ => problems}/p0059.rs (95%) rename rust/src/{ => problems}/p0067.rs (100%) rename rust/src/{ => problems}/p0069.rs (100%) rename rust/src/{ => problems}/p0076.rs (100%) rename rust/src/{ => problems}/p0077.rs (94%) rename rust/src/{ => problems}/p0087.rs (100%) rename rust/src/{ => problems}/p0187.rs (100%) rename rust/src/{ => problems}/p0357.rs (100%) rename rust/src/{ => problems}/p0836.rs (100%) diff --git a/docs/conf.py b/docs/conf.py index e600b334..7f7ccc7c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -217,7 +217,7 @@ def countfiles(lang): 'Python': ['Unity', 'docs'], 'C': ['c/Unity', 'cplusplus'], 'C++': ['c/', 'cplusplus/Unity'], - 'JavaScript': ['node_modules', 'dist', 'target'], + 'JavaScript': ['node_modules', 'dist', 'target', 'docs'], 'Rust': ['Unity'], } count = 0 diff --git a/docs/src/python/lib/fibonacci.rst b/docs/src/python/lib/fibonacci.rst index c8edd5ae..9142c1d6 100644 --- a/docs/src/python/lib/fibonacci.rst +++ b/docs/src/python/lib/fibonacci.rst @@ -16,4 +16,4 @@ Includes :language: python :linenos: -.. tags:: python-iterator, fibonacci +.. tags:: python-iterator, fibonacci-number diff --git a/docs/src/rust/p0001.rst b/docs/src/rust/p0001.rst index 5cabac0b..4c429c3b 100644 --- a/docs/src/rust/p0001.rst +++ b/docs/src/rust/p0001.rst @@ -1,11 +1,11 @@ Rust Implementation of Problem 1 ================================ -View source code :source:`rust/src/p0001.rs` +View source code :source:`rust/src/problems/p0001.rs` -.. rust:fn:: pub fn p0001::p0001() -> utils::Answer +.. rust:fn:: pub fn problems::p0001::p0001() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0001.rs +.. literalinclude:: ../../../rust/src/problems/p0001.rs :language: rust :linenos: diff --git a/docs/src/rust/p0002.rst b/docs/src/rust/p0002.rst index 8c831ca6..7520e892 100644 --- a/docs/src/rust/p0002.rst +++ b/docs/src/rust/p0002.rst @@ -1,11 +1,11 @@ Rust Implementation of Problem 2 ================================ -View source code :source:`rust/src/p0002.rs` +View source code :source:`rust/src/problems/p0002.rs` -.. rust:fn:: pub fn p0002::p0002() -> utils::Answer +.. rust:fn:: pub fn problems::p0002::p0002() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0002.rs +.. literalinclude:: ../../../rust/src/problems/p0002.rs :language: rust :linenos: diff --git a/docs/src/rust/p0003.rst b/docs/src/rust/p0003.rst index 7882656b..24eb1acb 100644 --- a/docs/src/rust/p0003.rst +++ b/docs/src/rust/p0003.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 3 ================================ -View source code :source:`rust/src/p0003.rs` +View source code :source:`rust/src/problems/p0003.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0003::p0003() -> utils::Answer +.. rust:fn:: pub fn problems::p0003::p0003() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0003.rs +.. literalinclude:: ../../../rust/src/problems/p0003.rs :language: rust :linenos: diff --git a/docs/src/rust/p0004.rst b/docs/src/rust/p0004.rst index 0930fe60..e54b3688 100644 --- a/docs/src/rust/p0004.rst +++ b/docs/src/rust/p0004.rst @@ -1,16 +1,16 @@ Rust Implementation of Problem 4 ================================ -View source code :source:`rust/src/p0004.rs` +View source code :source:`rust/src/problems/p0004.rs` Problem Solution ---------------- .. rust:fn:: fn p0004::is_palindrome(x: u32) -> bool -.. rust:fn:: pub fn p0004::p0004() -> utils::Answer +.. rust:fn:: pub fn problems::p0004::p0004() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0004.rs +.. literalinclude:: ../../../rust/src/problems/p0004.rs :language: rust :linenos: diff --git a/docs/src/rust/p0005.rst b/docs/src/rust/p0005.rst index a1622a8a..8ee79007 100644 --- a/docs/src/rust/p0005.rst +++ b/docs/src/rust/p0005.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 5 ================================ -View source code :source:`rust/src/p0005.rs` +View source code :source:`rust/src/problems/p0005.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0005::p0005() -> utils::Answer +.. rust:fn:: pub fn problems::p0005::p0005() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0005.rs +.. literalinclude:: ../../../rust/src/problems/p0005.rs :language: rust :linenos: diff --git a/docs/src/rust/p0006.rst b/docs/src/rust/p0006.rst index 4c381f26..d041ad51 100644 --- a/docs/src/rust/p0006.rst +++ b/docs/src/rust/p0006.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 6 ================================ -View source code :source:`rust/src/p0006.rs` +View source code :source:`rust/src/problems/p0006.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0006::p0006() -> utils::Answer +.. rust:fn:: pub fn problems::p0006::p0006() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0006.rs +.. literalinclude:: ../../../rust/src/problems/p0006.rs :language: rust :linenos: diff --git a/docs/src/rust/p0007.rst b/docs/src/rust/p0007.rst index 152bf2bd..ff2e92d0 100644 --- a/docs/src/rust/p0007.rst +++ b/docs/src/rust/p0007.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 7 ================================ -View source code :source:`rust/src/p0007.rs` +View source code :source:`rust/src/problems/p0007.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0007::p0007() -> utils::Answer +.. rust:fn:: pub fn problems::p0007::p0007() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0007.rs +.. literalinclude:: ../../../rust/src/problems/p0007.rs :language: rust :linenos: diff --git a/docs/src/rust/p0008.rst b/docs/src/rust/p0008.rst index 5db9a541..49a55ce2 100644 --- a/docs/src/rust/p0008.rst +++ b/docs/src/rust/p0008.rst @@ -1,13 +1,13 @@ Rust Implementation of Problem 8 ================================ -View source code :source:`rust/src/p0008.rs` +View source code :source:`rust/src/problems/p0008.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0008::p0008() -> utils::Answer +.. rust:fn:: pub fn problems::p0008::p0008() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0008.rs +.. literalinclude:: ../../../rust/src/problems/p0008.rs :language: rust :linenos: diff --git a/docs/src/rust/p0009.rst b/docs/src/rust/p0009.rst index eeeed381..c7b0404b 100644 --- a/docs/src/rust/p0009.rst +++ b/docs/src/rust/p0009.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 9 ================================ -View source code :source:`rust/src/p0009.rs` +View source code :source:`rust/src/problems/p0009.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0009::p0009() -> utils::Answer +.. rust:fn:: pub fn problems::p0009::p0009() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0009.rs +.. literalinclude:: ../../../rust/src/problems/p0009.rs :language: rust :linenos: diff --git a/docs/src/rust/p0010.rst b/docs/src/rust/p0010.rst index a4dbba26..ec80638b 100644 --- a/docs/src/rust/p0010.rst +++ b/docs/src/rust/p0010.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 10 ================================= -View source code :source:`rust/src/p0010.rs` +View source code :source:`rust/src/problems/p0010.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0010::p0010() -> utils::Answer +.. rust:fn:: pub fn problems::p0010::p0010() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0010.rs +.. literalinclude:: ../../../rust/src/problems/p0010.rs :language: rust :linenos: diff --git a/docs/src/rust/p0011.rst b/docs/src/rust/p0011.rst index de48568a..ba65fd4e 100644 --- a/docs/src/rust/p0011.rst +++ b/docs/src/rust/p0011.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 11 ================================= -View source code :source:`rust/src/p0011.rs` +View source code :source:`rust/src/problems/p0011.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0011::p0011() -> utils::Answer +.. rust:fn:: pub fn problems::p0011::p0011() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0011.rs +.. literalinclude:: ../../../rust/src/problems/p0011.rs :language: rust :linenos: diff --git a/docs/src/rust/p0012.rst b/docs/src/rust/p0012.rst index b376bb2a..c61a5118 100644 --- a/docs/src/rust/p0012.rst +++ b/docs/src/rust/p0012.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 12 ================================= -View source code :source:`rust/src/p0012.rs` +View source code :source:`rust/src/problems/p0012.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0012::p0012() -> utils::Answer +.. rust:fn:: pub fn problems::p0012::p0012() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0012.rs +.. literalinclude:: ../../../rust/src/problems/p0012.rs :language: rust :linenos: diff --git a/docs/src/rust/p0013.rst b/docs/src/rust/p0013.rst index 0794c3e6..13b5c52e 100644 --- a/docs/src/rust/p0013.rst +++ b/docs/src/rust/p0013.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 13 ================================= -View source code :source:`rust/src/p0013.rs` +View source code :source:`rust/src/problems/p0013.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0013::p0013() -> utils::Answer +.. rust:fn:: pub fn problems::p0013::p0013() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0013.rs +.. literalinclude:: ../../../rust/src/problems/p0013.rs :language: rust :linenos: diff --git a/docs/src/rust/p0014.rst b/docs/src/rust/p0014.rst index c307afdc..78b3d3e7 100644 --- a/docs/src/rust/p0014.rst +++ b/docs/src/rust/p0014.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 14 ================================= -View source code :source:`rust/src/p0014.rs` +View source code :source:`rust/src/problems/p0014.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0014::p0014() -> utils::Answer +.. rust:fn:: pub fn problems::p0014::p0014() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0014.rs +.. literalinclude:: ../../../rust/src/problems/p0014.rs :language: rust :linenos: diff --git a/docs/src/rust/p0015.rst b/docs/src/rust/p0015.rst index 1435c612..8238daed 100644 --- a/docs/src/rust/p0015.rst +++ b/docs/src/rust/p0015.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 15 ================================= -View source code :source:`rust/src/p0015.rs` +View source code :source:`rust/src/problems/p0015.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0015::p0015() -> utils::Answer +.. rust:fn:: pub fn problems::p0015::p0015() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0015.rs +.. literalinclude:: ../../../rust/src/problems/p0015.rs :language: rust :linenos: diff --git a/docs/src/rust/p0016.rst b/docs/src/rust/p0016.rst index bf0afd08..054add5d 100644 --- a/docs/src/rust/p0016.rst +++ b/docs/src/rust/p0016.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 16 ================================= -View source code :source:`rust/src/p0016.rs` +View source code :source:`rust/src/problems/p0016.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0016::p0016() -> utils::Answer +.. rust:fn:: pub fn problems::p0016::p0016() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0016.rs +.. literalinclude:: ../../../rust/src/problems/p0016.rs :language: rust :linenos: diff --git a/docs/src/rust/p0017.rst b/docs/src/rust/p0017.rst index 127b063b..64c78bd1 100644 --- a/docs/src/rust/p0017.rst +++ b/docs/src/rust/p0017.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 17 ================================= -View source code :source:`rust/src/p0017.rs` +View source code :source:`rust/src/problems/p0017.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0017::p0017() -> utils::Answer +.. rust:fn:: pub fn problems::p0017::p0017() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0017.rs +.. literalinclude:: ../../../rust/src/problems/p0017.rs :language: rust :linenos: diff --git a/docs/src/rust/p0018.rst b/docs/src/rust/p0018.rst index 35884b9d..40d9a39c 100644 --- a/docs/src/rust/p0018.rst +++ b/docs/src/rust/p0018.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 18 ================================= -View source code :source:`rust/src/p0018.rs` +View source code :source:`rust/src/problems/p0018.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0018::p0018() -> utils::Answer +.. rust:fn:: pub fn problems::p0018::p0018() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0018.rs +.. literalinclude:: ../../../rust/src/problems/p0018.rs :language: rust :linenos: diff --git a/docs/src/rust/p0019.rst b/docs/src/rust/p0019.rst index a25f3afd..a8cb480b 100644 --- a/docs/src/rust/p0019.rst +++ b/docs/src/rust/p0019.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 19 ================================= -View source code :source:`rust/src/p0019.rs` +View source code :source:`rust/src/problems/p0019.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0019::p0019() -> utils::Answer +.. rust:fn:: pub fn problems::p0019::p0019() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0019.rs +.. literalinclude:: ../../../rust/src/problems/p0019.rs :language: rust :linenos: diff --git a/docs/src/rust/p0020.rst b/docs/src/rust/p0020.rst index 7593bc5b..4767bbdf 100644 --- a/docs/src/rust/p0020.rst +++ b/docs/src/rust/p0020.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 20 ================================= -View source code :source:`rust/src/p0020.rs` +View source code :source:`rust/src/problems/p0020.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0020::p0020() -> utils::Answer +.. rust:fn:: pub fn problems::p0020::p0020() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0020.rs +.. literalinclude:: ../../../rust/src/problems/p0020.rs :language: rust :linenos: diff --git a/docs/src/rust/p0021.rst b/docs/src/rust/p0021.rst index a221da9f..25eb2727 100644 --- a/docs/src/rust/p0021.rst +++ b/docs/src/rust/p0021.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 21 ================================= -View source code :source:`rust/src/p0021.rs` +View source code :source:`rust/src/problems/p0021.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0021::p0021() -> utils::Answer +.. rust:fn:: pub fn problems::p0021::p0021() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0021.rs +.. literalinclude:: ../../../rust/src/problems/p0021.rs :language: rust :linenos: diff --git a/docs/src/rust/p0022.rst b/docs/src/rust/p0022.rst index 91866727..150e049a 100644 --- a/docs/src/rust/p0022.rst +++ b/docs/src/rust/p0022.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 22 ================================= -View source code :source:`rust/src/p0022.rs` +View source code :source:`rust/src/problems/p0022.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0022::p0022() -> utils::Answer +.. rust:fn:: pub fn problems::p0022::p0022() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0022.rs +.. literalinclude:: ../../../rust/src/problems/p0022.rs :language: rust :linenos: diff --git a/docs/src/rust/p0023.rst b/docs/src/rust/p0023.rst index a397ca72..133a9599 100644 --- a/docs/src/rust/p0023.rst +++ b/docs/src/rust/p0023.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 23 ================================= -View source code :source:`rust/src/p0023.rs` +View source code :source:`rust/src/problems/p0023.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0023::p0023() -> utils::Answer +.. rust:fn:: pub fn problems::p0023::p0023() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0023.rs +.. literalinclude:: ../../../rust/src/problems/p0023.rs :language: rust :linenos: diff --git a/docs/src/rust/p0024.rst b/docs/src/rust/p0024.rst index 1557a7da..af2816c1 100644 --- a/docs/src/rust/p0024.rst +++ b/docs/src/rust/p0024.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 24 ================================= -View source code :source:`rust/src/p0024.rs` +View source code :source:`rust/src/problems/p0024.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0024::p0024() -> utils::Answer +.. rust:fn:: pub fn problems::p0024::p0024() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0024.rs +.. literalinclude:: ../../../rust/src/problems/p0024.rs :language: rust :linenos: diff --git a/docs/src/rust/p0025.rst b/docs/src/rust/p0025.rst index d84cf227..37bad299 100644 --- a/docs/src/rust/p0025.rst +++ b/docs/src/rust/p0025.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 25 ================================= -View source code :source:`rust/src/p0025.rs` +View source code :source:`rust/src/problems/p0025.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0025::p0025() -> utils::Answer +.. rust:fn:: pub fn problems::p0025::p0025() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0025.rs +.. literalinclude:: ../../../rust/src/problems/p0025.rs :language: rust :linenos: diff --git a/docs/src/rust/p0027.rst b/docs/src/rust/p0027.rst index 1bb45575..3db9aa07 100644 --- a/docs/src/rust/p0027.rst +++ b/docs/src/rust/p0027.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 27 ================================= -View source code :source:`rust/src/p0027.rs` +View source code :source:`rust/src/problems/p0027.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0027::p0027() -> utils::Answer +.. rust:fn:: pub fn problems::p0027::p0027() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0027.rs +.. literalinclude:: ../../../rust/src/problems/p0027.rs :language: rust :linenos: diff --git a/docs/src/rust/p0034.rst b/docs/src/rust/p0034.rst index 61aa69db..a172656a 100644 --- a/docs/src/rust/p0034.rst +++ b/docs/src/rust/p0034.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 34 ================================= -View source code :source:`rust/src/p0034.rs` +View source code :source:`rust/src/problems/p0034.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0034::p0034() -> utils::Answer +.. rust:fn:: pub fn problems::p0034::p0034() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0034.rs +.. literalinclude:: ../../../rust/src/problems/p0034.rs :language: rust :linenos: diff --git a/docs/src/rust/p0035.rst b/docs/src/rust/p0035.rst index edb92e43..6b704065 100644 --- a/docs/src/rust/p0035.rst +++ b/docs/src/rust/p0035.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 35 ================================= -View source code :source:`rust/src/p0035.rs` +View source code :source:`rust/src/problems/p0035.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0035::p0035() -> utils::Answer +.. rust:fn:: pub fn problems::p0035::p0035() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0035.rs +.. literalinclude:: ../../../rust/src/problems/p0035.rs :language: rust :linenos: diff --git a/docs/src/rust/p0036.rst b/docs/src/rust/p0036.rst index 56e52700..9d8ff007 100644 --- a/docs/src/rust/p0036.rst +++ b/docs/src/rust/p0036.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 36 ================================= -View source code :source:`rust/src/p0036.rs` +View source code :source:`rust/src/problems/p0036.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0036::p0036() -> utils::Answer +.. rust:fn:: pub fn problems::p0036::p0036() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0036.rs +.. literalinclude:: ../../../rust/src/problems/p0036.rs :language: rust :linenos: diff --git a/docs/src/rust/p0037.rst b/docs/src/rust/p0037.rst index 3c5a28ad..0996c37f 100644 --- a/docs/src/rust/p0037.rst +++ b/docs/src/rust/p0037.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 37 ================================= -View source code :source:`rust/src/p0037.rs` +View source code :source:`rust/src/problems/p0037.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0037::p0037() -> utils::Answer +.. rust:fn:: pub fn problems::p0037::p0037() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0037.rs +.. literalinclude:: ../../../rust/src/problems/p0037.rs :language: rust :linenos: diff --git a/docs/src/rust/p0041.rst b/docs/src/rust/p0041.rst index d5267102..6c611d85 100644 --- a/docs/src/rust/p0041.rst +++ b/docs/src/rust/p0041.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 41 ================================= -View source code :source:`rust/src/p0041.rs` +View source code :source:`rust/src/problems/p0041.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0041::p0041() -> utils::Answer +.. rust:fn:: pub fn problems::p0041::p0041() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0041.rs +.. literalinclude:: ../../../rust/src/problems/p0041.rs :language: rust :linenos: diff --git a/docs/src/rust/p0044.rst b/docs/src/rust/p0044.rst index f768f49a..ead650ac 100644 --- a/docs/src/rust/p0044.rst +++ b/docs/src/rust/p0044.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 44 ================================= -View source code :source:`rust/src/p0044.rs` +View source code :source:`rust/src/problems/p0044.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0044::p0044() -> utils::Answer +.. rust:fn:: pub fn problems::p0044::p0044() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0044.rs +.. literalinclude:: ../../../rust/src/problems/p0044.rs :language: rust :linenos: diff --git a/docs/src/rust/p0045.rst b/docs/src/rust/p0045.rst index c7e8f9cc..5fd86ff1 100644 --- a/docs/src/rust/p0045.rst +++ b/docs/src/rust/p0045.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 45 ================================= -View source code :source:`rust/src/p0045.rs` +View source code :source:`rust/src/problems/p0045.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0045::p0045() -> utils::Answer +.. rust:fn:: pub fn problems::p0045::p0045() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0045.rs +.. literalinclude:: ../../../rust/src/problems/p0045.rs :language: rust :linenos: diff --git a/docs/src/rust/p0053.rst b/docs/src/rust/p0053.rst index 7c6845e8..5f3449fd 100644 --- a/docs/src/rust/p0053.rst +++ b/docs/src/rust/p0053.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 53 ================================= -View source code :source:`rust/src/p0053.rs` +View source code :source:`rust/src/problems/p0053.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0053::p0053() -> utils::Answer +.. rust:fn:: pub fn problems::p0053::p0053() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0053.rs +.. literalinclude:: ../../../rust/src/problems/p0053.rs :language: rust :linenos: diff --git a/docs/src/rust/p0059.rst b/docs/src/rust/p0059.rst index 6b3ab0f5..66675398 100644 --- a/docs/src/rust/p0059.rst +++ b/docs/src/rust/p0059.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 59 ================================= -View source code :source:`rust/src/p0059.rs` +View source code :source:`rust/src/problems/p0059.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0059::p0059() -> utils::Answer +.. rust:fn:: pub fn problems::p0059::p0059() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0059.rs +.. literalinclude:: ../../../rust/src/problems/p0059.rs :language: rust :linenos: diff --git a/docs/src/rust/p0067.rst b/docs/src/rust/p0067.rst index f2cbd809..654250b4 100644 --- a/docs/src/rust/p0067.rst +++ b/docs/src/rust/p0067.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 67 ================================= -View source code :source:`rust/src/p0067.rs` +View source code :source:`rust/src/problems/p0067.rs` Includes -------- @@ -12,9 +12,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0067::p0067() -> utils::Answer +.. rust:fn:: pub fn problems::p0067::p0067() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0067.rs +.. literalinclude:: ../../../rust/src/problems/p0067.rs :language: rust :linenos: diff --git a/docs/src/rust/p0069.rst b/docs/src/rust/p0069.rst index 3cc2a52c..bb228048 100644 --- a/docs/src/rust/p0069.rst +++ b/docs/src/rust/p0069.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 69 ================================= -View source code :source:`rust/src/p0069.rs` +View source code :source:`rust/src/problems/p0069.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0069::p0069() -> utils::Answer +.. rust:fn:: pub fn problems::p0069::p0069() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0069.rs +.. literalinclude:: ../../../rust/src/problems/p0069.rs :language: rust :linenos: diff --git a/docs/src/rust/p0076.rst b/docs/src/rust/p0076.rst index a64b491b..e933fac5 100644 --- a/docs/src/rust/p0076.rst +++ b/docs/src/rust/p0076.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 76 ================================= -View source code :source:`rust/src/p0076.rs` +View source code :source:`rust/src/problems/p0076.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0076::p0076() -> utils::Answer +.. rust:fn:: pub fn problems::p0076::p0076() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0076.rs +.. literalinclude:: ../../../rust/src/problems/p0076.rs :language: rust :linenos: diff --git a/docs/src/rust/p0077.rst b/docs/src/rust/p0077.rst index 25e99373..4880f89f 100644 --- a/docs/src/rust/p0077.rst +++ b/docs/src/rust/p0077.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 77 ================================= -View source code :source:`rust/src/p0077.rs` +View source code :source:`rust/src/problems/p0077.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0077::p0077() -> utils::Answer +.. rust:fn:: pub fn problems::p0077::p0077() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0077.rs +.. literalinclude:: ../../../rust/src/problems/p0077.rs :language: rust :linenos: diff --git a/docs/src/rust/p0087.rst b/docs/src/rust/p0087.rst index d6998a67..c2bea727 100644 --- a/docs/src/rust/p0087.rst +++ b/docs/src/rust/p0087.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 87 ================================= -View source code :source:`rust/src/p0087.rs` +View source code :source:`rust/src/problems/p0087.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0087::p0087() -> utils::Answer +.. rust:fn:: pub fn problems::p0087::p0087() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0087.rs +.. literalinclude:: ../../../rust/src/problems/p0087.rs :language: rust :linenos: diff --git a/docs/src/rust/p0187.rst b/docs/src/rust/p0187.rst index 22751496..00e96d54 100644 --- a/docs/src/rust/p0187.rst +++ b/docs/src/rust/p0187.rst @@ -1,7 +1,7 @@ Rust Implementation of Problem 187 ================================== -View source code :source:`rust/src/p0187.rs` +View source code :source:`rust/src/problems/p0187.rs` Includes -------- @@ -11,9 +11,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0187::p0187() -> utils::Answer +.. rust:fn:: pub fn problems::p0187::p0187() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0187.rs +.. literalinclude:: ../../../rust/src/problems/p0187.rs :language: rust :linenos: diff --git a/docs/src/rust/p0357.rst b/docs/src/rust/p0357.rst index e78a3d51..a366bd35 100644 --- a/docs/src/rust/p0357.rst +++ b/docs/src/rust/p0357.rst @@ -6,7 +6,7 @@ Rust Implementation of Problem 357 While this is a complete solution, and will eventually complete, until ``proper_divisors()`` returns an iterator (as opposed to the current implementation that returns a vector) it will be quite slow. That conversion is underway. -View source code :source:`rust/src/p0357.rs` +View source code :source:`rust/src/problems/p0357.rs` Includes -------- @@ -16,9 +16,9 @@ Includes Problem Solution ---------------- -.. rust:fn:: pub fn p0357::p0357() -> utils::Answer +.. rust:fn:: pub fn problems::p0357::p0357() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0357.rs +.. literalinclude:: ../../../rust/src/problems/p0357.rs :language: rust :linenos: diff --git a/docs/src/rust/p0836.rst b/docs/src/rust/p0836.rst index 4e47766e..7eb8e5dd 100644 --- a/docs/src/rust/p0836.rst +++ b/docs/src/rust/p0836.rst @@ -1,14 +1,14 @@ Rust Implementation of Problem 836 ================================== -View source code :source:`rust/src/p0836.rs` +View source code :source:`rust/src/problems/p0836.rs` Problem Solution ---------------- -.. rust:fn:: pub fn p0836::p0836() -> utils::Answer +.. rust:fn:: pub fn problems::p0836::p0836() -> utils::Answer -.. literalinclude:: ../../../rust/src/p0836.rs +.. literalinclude:: ../../../rust/src/problems/p0836.rs :language: rust :linenos: diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d528728f..a3b0dbf0 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -18,7 +18,7 @@ num-traits = "0.2.19" seq-macro = "0.3.5" [dev-dependencies] -rstest = "0.21.0" +rstest = { version = "0.21.0", default-features = false } [target.'cfg(any(target_arch="wasm32",target_arch="wasm64"))'.dependencies] js-sys = "0.3" diff --git a/rust/README.rst b/rust/README.rst index 3b832cf0..c134cbf1 100644 --- a/rust/README.rst +++ b/rust/README.rst @@ -58,46 +58,45 @@ dependencies for this section. Problems Solved --------------- -- ☒ `1 <./src/p0001.rs>`__ -- ☒ `2 <./src/p0002.rs>`__ -- ☒ `3 <./src/p0003.rs>`__ -- ☒ `4 <./src/p0004.rs>`__ -- ☒ `5 <./src/p0005.rs>`__ -- ☒ `6 <./src/p0006.rs>`__ -- ☒ `7 <./src/p0007.rs>`__ -- ☒ `8 <./src/p0008.rs>`__ -- ☒ `9 <./src/p0009.rs>`__ -- ☒ `10 <./src/p0010.rs>`__ -- ☒ `11 <./src/p0011.rs>`__ -- ☒ `12 <./src/p0012.rs>`__ -- ☒ `14 <./src/p0014.rs>`__ -- ☒ `15 <./src/p0015.rs>`__ -- ☒ `16 <./src/p0016.rs>`__ -- ☒ `17 <./src/p0017.rs>`__ -- ☒ `18 <./src/p0018.rs>`__ -- ☒ `19 <./src/p0019.rs>`__ -- ☒ `20 <./src/p0020.rs>`__ -- ☒ `21 <./src/p0021.rs>`__ -- ☒ `22 <./src/p0022.rs>`__ -- ☒ `23 <./src/p0023.rs>`__ -- ☒ `24 <./src/p0024.rs>`__ -- ☒ `25 <./src/p0025.rs>`__ -- ☒ `27 <./src/p0027.rs>`__ -- ☒ `34 <./src/p0034.rs>`__ -- ☒ `35 <./src/p0035.rs>`__ -- ☒ `36 <./src/p0036.rs>`__ -- ☒ `37 <./src/p0037.rs>`__ -- ☒ `41 <./src/p0041.rs>`__ -- ☒ `44 <./src/p0044.rs>`__ -- ☒ `45 <./src/p0045.rs>`__ -- ☒ `53 <./src/p0053.rs>`__ -- ☒ `59 <./src/p0059.rs>`__ -- ☒ `67 <./src/p0067.rs>`__ -- ☒ `69 <./src/p0069.rs>`__ -- ☒ `76 <./src/p0076.rs>`__ -- ☒ `77 <./src/p0077.rs>`__ -- ☒ `87 <./src/p0087.rs>`__ -- ☒ `187 <./src/p0187.rs>`__ -- ☒ `357 <./src/p0357.rs>`__ -- ☒ `836 <./src/p0836.rs>`__ - +- ☒ `1 <./src/problems/p0001.rs>`__ +- ☒ `2 <./src/problems/p0002.rs>`__ +- ☒ `3 <./src/problems/p0003.rs>`__ +- ☒ `4 <./src/problems/p0004.rs>`__ +- ☒ `5 <./src/problems/p0005.rs>`__ +- ☒ `6 <./src/problems/p0006.rs>`__ +- ☒ `7 <./src/problems/p0007.rs>`__ +- ☒ `8 <./src/problems/p0008.rs>`__ +- ☒ `9 <./src/problems/p0009.rs>`__ +- ☒ `10 <./src/problems/p0010.rs>`__ +- ☒ `11 <./src/problems/p0011.rs>`__ +- ☒ `12 <./src/problems/p0012.rs>`__ +- ☒ `14 <./src/problems/p0014.rs>`__ +- ☒ `15 <./src/problems/p0015.rs>`__ +- ☒ `16 <./src/problems/p0016.rs>`__ +- ☒ `17 <./src/problems/p0017.rs>`__ +- ☒ `18 <./src/problems/p0018.rs>`__ +- ☒ `19 <./src/problems/p0019.rs>`__ +- ☒ `20 <./src/problems/p0020.rs>`__ +- ☒ `21 <./src/problems/p0021.rs>`__ +- ☒ `22 <./src/problems/p0022.rs>`__ +- ☒ `23 <./src/problems/p0023.rs>`__ +- ☒ `24 <./src/problems/p0024.rs>`__ +- ☒ `25 <./src/problems/p0025.rs>`__ +- ☒ `27 <./src/problems/p0027.rs>`__ +- ☒ `34 <./src/problems/p0034.rs>`__ +- ☒ `35 <./src/problems/p0035.rs>`__ +- ☒ `36 <./src/problems/p0036.rs>`__ +- ☒ `37 <./src/problems/p0037.rs>`__ +- ☒ `41 <./src/problems/p0041.rs>`__ +- ☒ `44 <./src/problems/p0044.rs>`__ +- ☒ `45 <./src/problems/p0045.rs>`__ +- ☒ `53 <./src/problems/p0053.rs>`__ +- ☒ `59 <./src/problems/p0059.rs>`__ +- ☒ `67 <./src/problems/p0067.rs>`__ +- ☒ `69 <./src/problems/p0069.rs>`__ +- ☒ `76 <./src/problems/p0076.rs>`__ +- ☒ `77 <./src/problems/p0077.rs>`__ +- ☒ `87 <./src/problems/p0087.rs>`__ +- ☒ `187 <./src/problems/p0187.rs>`__ +- ☒ `357 <./src/problems/p0357.rs>`__ +- ☒ `836 <./src/problems/p0836.rs>`__ diff --git a/rust/src/include/problems.rs b/rust/src/include/problems.rs index 7c2dbd65..5ab7a164 100644 --- a/rust/src/include/problems.rs +++ b/rust/src/include/problems.rs @@ -1,26 +1,7 @@ use seq_macro::seq; use crate::include::utils::Answer; -seq!(N in 0001..=0025 { - use crate::p~N::p~N; -}); -use crate::p0027::p0027; -seq!(N in 0034..=0037 { - use crate::p~N::p~N; -}); -use crate::p0041::p0041; -use crate::p0044::p0044; -use crate::p0045::p0045; -use crate::p0053::p0053; -use crate::p0059::p0059; -use crate::p0067::p0067; -use crate::p0069::p0069; -use crate::p0076::p0076; -use crate::p0077::p0077; -use crate::p0087::p0087; -use crate::p0187::p0187; -use crate::p0357::p0357; -use crate::p0836::p0836; +use crate::problems::*; type ProblemType = fn() -> Answer; type ProblemRef<'a> = (&'a usize, ProblemType, bool); @@ -29,31 +10,31 @@ seq!(N in 0001..=0020 { pub fn get_problem<'b>(n: usize) -> Option> { return match n { #( - N => Some(( &N, p~N, false)), + N => Some(( &N, p~N::p~N, false)), )* - 21 => Some(( &21, p0021, true)), - 22 => Some(( &22, p0022, false)), - 23 => Some(( &23, p0023, false)), - 24 => Some(( &24, p0024, false)), - 25 => Some(( &25, p0025, false)), - 27 => Some(( &27, p0027, true)), - 34 => Some(( &34, p0034, false)), - 35 => Some(( &35, p0035, true)), - 36 => Some(( &36, p0036, false)), - 37 => Some(( &37, p0037, true)), - 41 => Some(( &41, p0041, false)), - 44 => Some(( &44, p0044, false)), - 45 => Some(( &45, p0045, false)), - 53 => Some(( &53, p0053, false)), - 59 => Some(( &59, p0059, false)), - 67 => Some(( &67, p0067, false)), - 69 => Some(( &69, p0069, false)), - 76 => Some(( &76, p0076, false)), - 77 => Some(( &77, p0077, false)), - 87 => Some(( &87, p0087, false)), - 187 => Some((&187, p0187, false)), - 357 => Some((&357, p0357, true)), - 836 => Some((&836, p0836, false)), + 21 => Some(( &21, p0021::p0021, true)), + 22 => Some(( &22, p0022::p0022, false)), + 23 => Some(( &23, p0023::p0023, false)), + 24 => Some(( &24, p0024::p0024, false)), + 25 => Some(( &25, p0025::p0025, false)), + 27 => Some(( &27, p0027::p0027, true)), + 34 => Some(( &34, p0034::p0034, false)), + 35 => Some(( &35, p0035::p0035, true)), + 36 => Some(( &36, p0036::p0036, false)), + 37 => Some(( &37, p0037::p0037, true)), + 41 => Some(( &41, p0041::p0041, false)), + 44 => Some(( &44, p0044::p0044, false)), + 45 => Some(( &45, p0045::p0045, false)), + 53 => Some(( &53, p0053::p0053, false)), + 59 => Some(( &59, p0059::p0059, false)), + 67 => Some(( &67, p0067::p0067, false)), + 69 => Some(( &69, p0069::p0069, false)), + 76 => Some(( &76, p0076::p0076, false)), + 77 => Some(( &77, p0077::p0077, false)), + 87 => Some(( &87, p0087::p0087, false)), + 187 => Some((&187, p0187::p0187, false)), + 357 => Some((&357, p0357::p0357, true)), + 836 => Some((&836, p0836::p0836, false)), _ => None, }; } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 7e6445c8..0a3f46dd 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -19,29 +19,9 @@ use rstest::rstest; #[cfg(test)] use itertools::Itertools; - use seq_macro::seq; -seq!(N in 0001..=0025 { - pub mod p~N; -}); -pub mod p0027; -seq!(N in 0034..=0037 { - pub mod p~N; -}); -pub mod p0041; -pub mod p0044; -pub mod p0045; -pub mod p0053; -pub mod p0059; -pub mod p0067; -pub mod p0069; -pub mod p0076; -pub mod p0077; -pub mod p0087; -pub mod p0187; -pub mod p0357; -pub mod p0836; +pub mod problems; pub mod include; pub use crate::include::*; pub use crate::include::problems::{generate_supported_problems,get_problem}; @@ -51,8 +31,7 @@ pub use crate::include::utils::*; #[wasm_bindgen] pub fn run_problem(n: usize) -> JsValue { let Some((_, problem_function, _)) = get_problem(n) else { return JsValue::UNDEFINED }; - let answer = problem_function(); - return match answer { + return match problem_function() { Answer::String(e) => JsValue::from_str(&e), Answer::Int(e) => JsValue::from(e), } @@ -74,8 +53,7 @@ pub fn get_problems(include_slow: bool) -> JsValue { #[cfg(any(target_arch="wasm32", target_arch="wasm64"))] #[wasm_bindgen] pub fn get_js_answer(n: usize) -> JsValue { - let answer = get_answer(n); - return match answer { + return match get_answer(n) { Answer::String(e) => JsValue::from_str(&e), Answer::Int(e) => JsValue::from(e), } @@ -112,20 +90,17 @@ seq!(N in 01..=20 { #[case::problem_836(836)] fn test_problem(#[case] id: usize) -> Result<(), String> { let Some((_, func, _slow)) = get_problem(id) else { panic!() }; - let answer = get_answer(id); let start = Instant::now(); let result = func(); let _elapsed = start.elapsed(); - assert_eq!(answer, result); + assert_eq!(get_answer(id), result); #[cfg(all(target_os = "linux", target_env = "gnu"))] { - if !_slow { - assert!( - _elapsed <= Duration::new(60, 0), - "Should take at most 60s, but actually took {:?}", - _elapsed - ); - } + assert!( + !_slow && _elapsed <= Duration::new(60, 0), + "Should take at most 60s, but actually took {:?}", + _elapsed + ); } Ok(()) } @@ -146,8 +121,7 @@ fn test_primes() -> Result<(), String> { #[test] fn test_prime_factors() -> Result<(), String> { for v in primes::primes_until::(256).combinations(2) { - let p = v[0]; - let s = v[1]; + let &[p, s] = &v[..]; assert!(primes::is_prime(p)); assert!(primes::is_prime(s)); assert!(primes::is_composite(p * s) != 0); @@ -179,7 +153,10 @@ fn test_proper_divisors() -> Result<(), String> { fn test_n_choose_r() -> Result<(), String> { for i in 0..68usize { for j in 0..i { - assert_eq!((0..i).combinations(j).count() as u128, math::n_choose_r::(i, j)); + assert_eq!( + (0..i).combinations(j).count() as u128, + math::n_choose_r::(i, j) + ); } } Ok(()) diff --git a/rust/src/problems/mod.rs b/rust/src/problems/mod.rs new file mode 100644 index 00000000..e1020a71 --- /dev/null +++ b/rust/src/problems/mod.rs @@ -0,0 +1,22 @@ +use seq_macro::seq; + +seq!(N in 0001..=0025 { + pub mod p~N; +}); +pub mod p0027; +seq!(N in 0034..=0037 { + pub mod p~N; +}); +pub mod p0041; +pub mod p0044; +pub mod p0045; +pub mod p0053; +pub mod p0059; +pub mod p0067; +pub mod p0069; +pub mod p0076; +pub mod p0077; +pub mod p0087; +pub mod p0187; +pub mod p0357; +pub mod p0836; diff --git a/rust/src/p0001.rs b/rust/src/problems/p0001.rs similarity index 100% rename from rust/src/p0001.rs rename to rust/src/problems/p0001.rs diff --git a/rust/src/p0002.rs b/rust/src/problems/p0002.rs similarity index 100% rename from rust/src/p0002.rs rename to rust/src/problems/p0002.rs diff --git a/rust/src/p0003.rs b/rust/src/problems/p0003.rs similarity index 100% rename from rust/src/p0003.rs rename to rust/src/problems/p0003.rs diff --git a/rust/src/p0004.rs b/rust/src/problems/p0004.rs similarity index 100% rename from rust/src/p0004.rs rename to rust/src/problems/p0004.rs diff --git a/rust/src/p0005.rs b/rust/src/problems/p0005.rs similarity index 100% rename from rust/src/p0005.rs rename to rust/src/problems/p0005.rs diff --git a/rust/src/p0006.rs b/rust/src/problems/p0006.rs similarity index 100% rename from rust/src/p0006.rs rename to rust/src/problems/p0006.rs diff --git a/rust/src/p0007.rs b/rust/src/problems/p0007.rs similarity index 100% rename from rust/src/p0007.rs rename to rust/src/problems/p0007.rs diff --git a/rust/src/p0008.rs b/rust/src/problems/p0008.rs similarity index 100% rename from rust/src/p0008.rs rename to rust/src/problems/p0008.rs diff --git a/rust/src/p0009.rs b/rust/src/problems/p0009.rs similarity index 100% rename from rust/src/p0009.rs rename to rust/src/problems/p0009.rs diff --git a/rust/src/p0010.rs b/rust/src/problems/p0010.rs similarity index 100% rename from rust/src/p0010.rs rename to rust/src/problems/p0010.rs diff --git a/rust/src/p0011.rs b/rust/src/problems/p0011.rs similarity index 100% rename from rust/src/p0011.rs rename to rust/src/problems/p0011.rs diff --git a/rust/src/p0012.rs b/rust/src/problems/p0012.rs similarity index 100% rename from rust/src/p0012.rs rename to rust/src/problems/p0012.rs diff --git a/rust/src/p0013.rs b/rust/src/problems/p0013.rs similarity index 100% rename from rust/src/p0013.rs rename to rust/src/problems/p0013.rs diff --git a/rust/src/p0014.rs b/rust/src/problems/p0014.rs similarity index 100% rename from rust/src/p0014.rs rename to rust/src/problems/p0014.rs diff --git a/rust/src/p0015.rs b/rust/src/problems/p0015.rs similarity index 100% rename from rust/src/p0015.rs rename to rust/src/problems/p0015.rs diff --git a/rust/src/p0016.rs b/rust/src/problems/p0016.rs similarity index 100% rename from rust/src/p0016.rs rename to rust/src/problems/p0016.rs diff --git a/rust/src/p0017.rs b/rust/src/problems/p0017.rs similarity index 100% rename from rust/src/p0017.rs rename to rust/src/problems/p0017.rs diff --git a/rust/src/p0018.rs b/rust/src/problems/p0018.rs similarity index 100% rename from rust/src/p0018.rs rename to rust/src/problems/p0018.rs diff --git a/rust/src/p0019.rs b/rust/src/problems/p0019.rs similarity index 100% rename from rust/src/p0019.rs rename to rust/src/problems/p0019.rs diff --git a/rust/src/p0020.rs b/rust/src/problems/p0020.rs similarity index 100% rename from rust/src/p0020.rs rename to rust/src/problems/p0020.rs diff --git a/rust/src/p0021.rs b/rust/src/problems/p0021.rs similarity index 100% rename from rust/src/p0021.rs rename to rust/src/problems/p0021.rs diff --git a/rust/src/p0022.rs b/rust/src/problems/p0022.rs similarity index 100% rename from rust/src/p0022.rs rename to rust/src/problems/p0022.rs diff --git a/rust/src/p0023.rs b/rust/src/problems/p0023.rs similarity index 100% rename from rust/src/p0023.rs rename to rust/src/problems/p0023.rs diff --git a/rust/src/p0024.rs b/rust/src/problems/p0024.rs similarity index 100% rename from rust/src/p0024.rs rename to rust/src/problems/p0024.rs diff --git a/rust/src/p0025.rs b/rust/src/problems/p0025.rs similarity index 100% rename from rust/src/p0025.rs rename to rust/src/problems/p0025.rs diff --git a/rust/src/p0027.rs b/rust/src/problems/p0027.rs similarity index 100% rename from rust/src/p0027.rs rename to rust/src/problems/p0027.rs diff --git a/rust/src/p0034.rs b/rust/src/problems/p0034.rs similarity index 100% rename from rust/src/p0034.rs rename to rust/src/problems/p0034.rs diff --git a/rust/src/p0035.rs b/rust/src/problems/p0035.rs similarity index 100% rename from rust/src/p0035.rs rename to rust/src/problems/p0035.rs diff --git a/rust/src/p0036.rs b/rust/src/problems/p0036.rs similarity index 100% rename from rust/src/p0036.rs rename to rust/src/problems/p0036.rs diff --git a/rust/src/p0037.rs b/rust/src/problems/p0037.rs similarity index 100% rename from rust/src/p0037.rs rename to rust/src/problems/p0037.rs diff --git a/rust/src/p0041.rs b/rust/src/problems/p0041.rs similarity index 100% rename from rust/src/p0041.rs rename to rust/src/problems/p0041.rs diff --git a/rust/src/p0044.rs b/rust/src/problems/p0044.rs similarity index 100% rename from rust/src/p0044.rs rename to rust/src/problems/p0044.rs diff --git a/rust/src/p0045.rs b/rust/src/problems/p0045.rs similarity index 100% rename from rust/src/p0045.rs rename to rust/src/problems/p0045.rs diff --git a/rust/src/p0053.rs b/rust/src/problems/p0053.rs similarity index 100% rename from rust/src/p0053.rs rename to rust/src/problems/p0053.rs diff --git a/rust/src/p0059.rs b/rust/src/problems/p0059.rs similarity index 95% rename from rust/src/p0059.rs rename to rust/src/problems/p0059.rs index 96c8c35a..46e91703 100644 --- a/rust/src/p0059.rs +++ b/rust/src/problems/p0059.rs @@ -41,8 +41,8 @@ pub fn p0059() -> Answer { .collect::>(); for key in b"abcdefghijklmnopqrtsuvwxyz".iter().permutations(3) { let plaintext = tokens.iter() - .enumerate() - .map(|(i, x)| *x ^ key[i % 3]) + .zip(key.into_iter().cycle()) + .map(|(&x, k)| x ^ k) .collect::>(); if plaintext.windows(keyword.len()).any(|w| w == keyword) { return Answer::Int( diff --git a/rust/src/p0067.rs b/rust/src/problems/p0067.rs similarity index 100% rename from rust/src/p0067.rs rename to rust/src/problems/p0067.rs diff --git a/rust/src/p0069.rs b/rust/src/problems/p0069.rs similarity index 100% rename from rust/src/p0069.rs rename to rust/src/problems/p0069.rs diff --git a/rust/src/p0076.rs b/rust/src/problems/p0076.rs similarity index 100% rename from rust/src/p0076.rs rename to rust/src/problems/p0076.rs diff --git a/rust/src/p0077.rs b/rust/src/problems/p0077.rs similarity index 94% rename from rust/src/p0077.rs rename to rust/src/problems/p0077.rs index 4c9f38ad..3c8acc66 100644 --- a/rust/src/p0077.rs +++ b/rust/src/problems/p0077.rs @@ -31,7 +31,7 @@ fn prime_summations(n: u64) -> u64 { // so for 5 + 5 + 3 + 2 it would be [1, 1, 2] counts[0] = n / 2; // primes[0] = 2 loop { - let mut total: u64= zip(counts.clone(), cached_primes.clone()).map(|(x, y)| x * y).sum(); + let mut total: u64 = zip(counts.clone(), cached_primes.clone()).map(|(x, y)| x * y).sum(); counts[0] += 1; if total > n { let mut idx: usize = 0; diff --git a/rust/src/p0087.rs b/rust/src/problems/p0087.rs similarity index 100% rename from rust/src/p0087.rs rename to rust/src/problems/p0087.rs diff --git a/rust/src/p0187.rs b/rust/src/problems/p0187.rs similarity index 100% rename from rust/src/p0187.rs rename to rust/src/problems/p0187.rs diff --git a/rust/src/p0357.rs b/rust/src/problems/p0357.rs similarity index 100% rename from rust/src/p0357.rs rename to rust/src/problems/p0357.rs diff --git a/rust/src/p0836.rs b/rust/src/problems/p0836.rs similarity index 100% rename from rust/src/p0836.rs rename to rust/src/problems/p0836.rs