From 56d0505de2e62c30374a558dc8d2a9e538257d05 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Tue, 30 Jul 2024 02:17:38 -0500 Subject: [PATCH] Solve p836 in all languages --- README.rst | 12 ++++++------ c/README.rst | 20 ++------------------ c/p0836.c | 32 ++++++++++++++++++++++++++++++++ c/test.c | 1 + c/test_euler.py | 1 + cplusplus/README.rst | 1 + cplusplus/p0836.cpp | 31 +++++++++++++++++++++++++++++++ cplusplus/test.cpp | 1 + cplusplus/test_euler.py | 1 + csharp/Euler.Test/test.cs | 5 +++-- csharp/Euler/p0000_template.cs | 6 +++--- csharp/Euler/p0001.cs | 4 ++-- csharp/Euler/p0002.cs | 6 +++--- csharp/Euler/p0004.cs | 10 +++++----- csharp/Euler/p0006.cs | 8 ++++---- csharp/Euler/p0008.cs | 4 ++-- csharp/Euler/p0009.cs | 4 ++-- csharp/Euler/p0011.cs | 6 +++--- csharp/Euler/p0017.cs | 10 +++++----- csharp/Euler/p0836.cs | 28 ++++++++++++++++++++++++++++ csharp/README.rst | 1 + docs/c/p0836.rst | 20 ++++++++++++++++++++ docs/cplusplus/p0836.rst | 19 +++++++++++++++++++ docs/csharp.rst | 2 +- docs/csharp/p0001.rst | 2 +- docs/csharp/p0002.rst | 2 +- docs/csharp/p0004.rst | 2 +- docs/csharp/p0006.rst | 2 +- docs/csharp/p0008.rst | 2 +- docs/csharp/p0009.rst | 2 +- docs/csharp/p0011.rst | 2 +- docs/csharp/p0017.rst | 2 +- docs/csharp/p0836.rst | 16 ++++++++++++++++ docs/index.rst | 2 ++ docs/javascript/p0836.rst | 10 ++++++++++ docs/python/p0836.rst | 22 ++++++++++++++++++++++ docs/rust/p0836.rst | 13 +++++++++++++ javascript/README.rst | 1 + javascript/euler.test.js | 1 + javascript/src/p0836.js | 22 ++++++++++++++++++++++ python/README.rst | 1 + python/p0836.py | 24 ++++++++++++++++++++++++ python/test_euler.py | 7 ++++--- rust/README.rst | 1 + rust/src/main.rs | 1 + rust/src/p0836.rs | 20 ++++++++++++++++++++ 46 files changed, 323 insertions(+), 67 deletions(-) create mode 100644 c/p0836.c create mode 100644 cplusplus/p0836.cpp create mode 100644 csharp/Euler/p0836.cs create mode 100644 docs/c/p0836.rst create mode 100644 docs/cplusplus/p0836.rst create mode 100644 docs/csharp/p0836.rst create mode 100644 docs/javascript/p0836.rst create mode 100644 docs/python/p0836.rst create mode 100644 docs/rust/p0836.rst create mode 100644 javascript/src/p0836.js create mode 100644 python/p0836.py create mode 100644 rust/src/p0836.rs diff --git a/README.rst b/README.rst index 616c0c45..d13319e2 100644 --- a/README.rst +++ b/README.rst @@ -40,29 +40,29 @@ LivInTheLookingGlass’s Project Euler solutions +------------+-------------------------+--------+-------------------+ | Language | Version | Solved | Status | +============+=========================+========+===================+ -| C | C99+ in: ``gcc``, |br| | 19 | |Ci| |br| | +| C | C99+ in: ``gcc``, |br| | 20 | |Ci| |br| | | | ``clang``, ``msvc``, | | |C-Cov| |br| | | | |br| ``pcc``, ``tcc`` | | |CodeQL| | +------------+-------------------------+--------+-------------------+ -| C++ | C++98+ in |br| | 12 | |Cpi| |br| | +| C++ | C++98+ in |br| | 13 | |Cpi| |br| | | | ``gcc``, ``clang`` |br| | | |Cp-Cov| |br| | | | C++14+ in ``msvc`` | | |CodeQL| | +------------+-------------------------+--------+-------------------+ -| C# | .NET 2+ | 8 | |C#i| |br| | +| C# | .NET 2+ | 9 | |C#i| |br| | | | | | |Cs-Cov| |br| | | | | | |CodeQL| | +------------+-------------------------+--------+-------------------+ -| JavaScript | Node 12+ |br| | 8 | |JavaScript| |br| | +| JavaScript | Node 12+ |br| | 9 | |JavaScript| |br| | | | Bun 0.6.10+ | | |Js-Cov| |br| | | | | | |CodeQL| |br| | | | | | |ESLint| | +------------+-------------------------+--------+-------------------+ -| Python | CPython 3.6+ |br| | 78 | |Python| |br| | +| Python | CPython 3.6+ |br| | 79 | |Python| |br| | | | Pypy 3.6+ |br| | | |Py-Cov| |br| | | | GraalPy 23.1+ | | |CodeQL| |br| | | | | | |PythonLint| | +------------+-------------------------+--------+-------------------+ -| Rust | 1.69+ | 24 | |Rust| |br| | +| Rust | 1.69+ | 25 | |Rust| |br| | | | | | |Rs-Cov| |br| | | | | | |RustClippy| | +------------+-------------------------+--------+-------------------+ diff --git a/c/README.rst b/c/README.rst index 62ee274d..c5f5ef83 100644 --- a/c/README.rst +++ b/c/README.rst @@ -164,37 +164,21 @@ Problems Solved --------------- - ☒ `1 <./p0001.c>`__ - - ☒ `2 <./p0002.c>`__ - - ☒ `3 <./p0003.c>`__ - - ☒ `4 <./p0004.c>`__ - - ☒ `5 <./p0005.c>`__ - - ☒ `6 <./p0006.c>`__ - - ☒ `7 <./p0007.c>`__ - - ☒ `8 <./p0008.c>`__ - - ☒ `9 <./p0009.c>`__ - - ☒ `10 <./p0010.c>`__ - - ☒ `11 <./p0011.c>`__ - -- ☐ `12 <./p0012.c>`__ - +- ☒ `12 <./p0012.c>`_ - ☒ `13 <./p0013.c>`__ - - ☒ `14 <./p0014.c>`__ - - ☒ `15 <./p0015.c>`__ - - ☒ `16 <./p0016.c>`__ - - ☒ `34 <./p0034.c>`__ - - ☒ `76 <./p0076.c>`__ +- ☒ `836 <./p0836.c>`__ diff --git a/c/p0836.c b/c/p0836.c new file mode 100644 index 00000000..350381ae --- /dev/null +++ b/c/p0836.c @@ -0,0 +1,32 @@ +/* +Project Euler Problem 836 + +Alright, this was funny + +Problem: + +Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + +We consider an **open oriented line section** U of A with normalized Haar measure m. + +Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the +**orthogonal kernel embedding** of U into A. + +Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. +*/ +#ifndef EULER_P0836 +#define EULER_P0836 +#include + +char *p0836() { + return "aprilfoolsjoke"; +} + +#ifndef UNITY_END +int main(int argc, char const *argv[]) { + char *answer = p0836(); + printf("%s", answer); + return 0; +} +#endif +#endif diff --git a/c/test.c b/c/test.c index c829d77f..e9cd2d13 100644 --- a/c/test.c +++ b/c/test.c @@ -19,6 +19,7 @@ #include "p0017.c" #include "p0034.c" #include "p0076.c" +#include "p0836.c" typedef struct { unsigned int id; diff --git a/c/test_euler.py b/c/test_euler.py index 682fab76..66c8e229 100644 --- a/c/test_euler.py +++ b/c/test_euler.py @@ -39,6 +39,7 @@ 17: 21124, 34: 40730, 76: 190569291, + 836: "aprilfoolsjoke", } # this is the set of problems where I have the right answer but wrong solution diff --git a/cplusplus/README.rst b/cplusplus/README.rst index c15e4f36..44d963a4 100644 --- a/cplusplus/README.rst +++ b/cplusplus/README.rst @@ -176,3 +176,4 @@ Problems Solved - ☒ `17 <./p0017.cpp>`__ - ☒ `34 <./p0034.cpp>`__ - ☒ `76 <./p0076.cpp>`__ +- ☒ `836 <./p0836.cpp>`__ diff --git a/cplusplus/p0836.cpp b/cplusplus/p0836.cpp new file mode 100644 index 00000000..8e0fb9c4 --- /dev/null +++ b/cplusplus/p0836.cpp @@ -0,0 +1,31 @@ +/* +Project Euler Problem 836 + +Alright, this was funny + +Problem: + +Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + +We consider an **open oriented line section** U of A with normalized Haar measure m. + +Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the +**orthogonal kernel embedding** of U into A. + +Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. +*/ +#ifndef EULER_P0836 +#define EULER_P0836 +#include + +std::string p0836() { + return "aprilfoolsjoke"; +} + +#ifndef UNITY_END +int main(int argc, char const *argv[]) { + std::cout << p0836() << std::endl; + return 0; +} +#endif +#endif diff --git a/cplusplus/test.cpp b/cplusplus/test.cpp index 79530e98..d1e47c63 100644 --- a/cplusplus/test.cpp +++ b/cplusplus/test.cpp @@ -19,6 +19,7 @@ #include "p0017.cpp" #include "p0034.cpp" #include "p0076.cpp" +#include "p0836.cpp" typedef struct { unsigned int id; diff --git a/cplusplus/test_euler.py b/cplusplus/test_euler.py index f9a6871f..fd6c3d0c 100644 --- a/cplusplus/test_euler.py +++ b/cplusplus/test_euler.py @@ -32,6 +32,7 @@ 17: 21124, 34: 40730, 76: 190569291, + 836: "aprilfoolsjoke", } # this is the set of problems where I have the right answer but wrong solution diff --git a/csharp/Euler.Test/test.cs b/csharp/Euler.Test/test.cs index 241f2015..91560f58 100644 --- a/csharp/Euler.Test/test.cs +++ b/csharp/Euler.Test/test.cs @@ -16,17 +16,18 @@ public static IEnumerable Data() yield return new object[] { typeof(p0009), 31875000 }; yield return new object[] { typeof(p0011), 70600674 }; yield return new object[] { typeof(p0017), 21124 }; + yield return new object[] { typeof(p0836), "aprilfoolsjoke" }; } [Theory] [MemberData(nameof(Data))] - public async Task EulerTest_Problem(Type problem, Int64 expected) + public async Task EulerTest_Problem(Type problem, object expected) { IEuler? prob; prob = (IEuler?)Activator.CreateInstance(problem); Assert.NotNull(prob); Stopwatch sw = Stopwatch.StartNew(); - Int64 result = await prob.Answer(); + object result = await prob.Answer(); sw.Stop(); Assert.Equal(expected, result); Assert.True(sw.Elapsed <= oneMinute); diff --git a/csharp/Euler/p0000_template.cs b/csharp/Euler/p0000_template.cs index 7df9c985..8f1a87cd 100644 --- a/csharp/Euler/p0000_template.cs +++ b/csharp/Euler/p0000_template.cs @@ -13,13 +13,13 @@ namespace Euler { public interface IEuler { - public Task Answer(); + public Task Answer(); } public class p0000 : IEuler { - public Task Answer() + public Task Answer() { - return Task.FromResult(0); + return Task.FromResult(0); } } } diff --git a/csharp/Euler/p0001.cs b/csharp/Euler/p0001.cs index 504b19d1..b916679c 100644 --- a/csharp/Euler/p0001.cs +++ b/csharp/Euler/p0001.cs @@ -18,7 +18,7 @@ namespace Euler { public class p0001 : IEuler { - public Task Answer() + public Task Answer() { int answer = 0; for (int i = 0; i < 1000; i += 3) @@ -30,7 +30,7 @@ public Task Answer() for (int i = 0; i < 1000; i += 15) answer -= i; - return Task.FromResult(answer); + return Task.FromResult(answer); } } } diff --git a/csharp/Euler/p0002.cs b/csharp/Euler/p0002.cs index 502fcd9b..ecab8af3 100644 --- a/csharp/Euler/p0002.cs +++ b/csharp/Euler/p0002.cs @@ -20,9 +20,9 @@ namespace Euler { public class p0002 : IEuler { - public Task Answer() + public Task Answer() { - Int64 answer = 0, + int answer = 0, i = 2, j = 8, tmp = 0; @@ -35,7 +35,7 @@ public Task Answer() j = tmp; } - return Task.FromResult(answer); + return Task.FromResult(answer); } } } diff --git a/csharp/Euler/p0004.cs b/csharp/Euler/p0004.cs index 44b7ab48..3b28304f 100644 --- a/csharp/Euler/p0004.cs +++ b/csharp/Euler/p0004.cs @@ -25,20 +25,20 @@ private static string Reverse(string s) return new string(charArray); } - private static bool IsPalindrome(Int64 x) + private static bool IsPalindrome(int x) { string rep = x.ToString(); return rep == Reverse(rep); } - public Task Answer() + public Task Answer() { - Int64 answer = 0; + int answer = 0; for (int v = 101; v < 1000; v++) { for (int u = 100; u < v; u++) { - Int64 p = u * v; + int p = u * v; if (IsPalindrome(p) && p > answer) { answer = p; @@ -46,7 +46,7 @@ public Task Answer() } } - return Task.FromResult(answer); + return Task.FromResult(answer); } } } diff --git a/csharp/Euler/p0006.cs b/csharp/Euler/p0006.cs index 561f8750..b9dbe53d 100644 --- a/csharp/Euler/p0006.cs +++ b/csharp/Euler/p0006.cs @@ -23,17 +23,17 @@ namespace Euler { public class p0006 : IEuler { - public Task Answer() + public Task Answer() { - Int64 sum_of_squares = 0, + int sum_of_squares = 0, sum = 0; for (int i = 1; i < 101; i++) { sum += i; sum_of_squares += i * i; } - Int64 square_of_sum = sum * sum; - return Task.FromResult(square_of_sum - sum_of_squares); + int square_of_sum = sum * sum; + return Task.FromResult(square_of_sum - sum_of_squares); } } } diff --git a/csharp/Euler/p0008.cs b/csharp/Euler/p0008.cs index c5678630..f221f1a0 100644 --- a/csharp/Euler/p0008.cs +++ b/csharp/Euler/p0008.cs @@ -40,7 +40,7 @@ namespace Euler public class p0008 : IEuler { private const int MAX = 500; - public Task Answer() + public Task Answer() { String str = String.Concat( "73167176531330624919225119674426574742355349194934", @@ -78,7 +78,7 @@ public Task Answer() answer = prod; } } - return Task.FromResult(answer); + return Task.FromResult(answer); } } } diff --git a/csharp/Euler/p0009.cs b/csharp/Euler/p0009.cs index 7f0b2e9e..6df5a600 100644 --- a/csharp/Euler/p0009.cs +++ b/csharp/Euler/p0009.cs @@ -19,7 +19,7 @@ namespace Euler { public class p0009 : IEuler { - public Task Answer() + public Task Answer() { for (int c = 3; ; c++) { @@ -32,7 +32,7 @@ public Task Answer() int a_square = a * a; if (a_square + b_square == c_square && a + b + c == 1000) { - return Task.FromResult(a * b * c); + return Task.FromResult(a * b * c); } } } diff --git a/csharp/Euler/p0011.cs b/csharp/Euler/p0011.cs index 179f0863..7cc67721 100644 --- a/csharp/Euler/p0011.cs +++ b/csharp/Euler/p0011.cs @@ -23,9 +23,9 @@ namespace Euler { public class p0011 : IEuler { - public Task Answer() + public Task Answer() { - Int64 answer = 0, tmp; + int answer = 0, tmp; for (byte i = 0; i < 20; i++) { for (byte j = 0; j < 17; j++) @@ -50,7 +50,7 @@ public Task Answer() answer = Math.Max(answer, tmp); } } - return Task.FromResult(answer); + return Task.FromResult(answer); } byte[][] grid = new byte[20][]{ diff --git a/csharp/Euler/p0017.cs b/csharp/Euler/p0017.cs index 9989a7b9..904f1018 100644 --- a/csharp/Euler/p0017.cs +++ b/csharp/Euler/p0017.cs @@ -23,18 +23,18 @@ namespace Euler { public class p0017 : IEuler { - public Task Answer() + public Task Answer() { - Int64 answer = 0; - for (Int64 x = 1; x < 1001; x += 1) + int answer = 0; + for (int x = 1; x < 1001; x += 1) { string str = to_string(x); answer += str.Replace(" ", "").Replace("-", "").Length; } - return Task.FromResult(answer); + return Task.FromResult(answer); } - static String to_string(Int64 n) + static String to_string(int n) { if (n >= 1000) { diff --git a/csharp/Euler/p0836.cs b/csharp/Euler/p0836.cs new file mode 100644 index 00000000..32a9b90d --- /dev/null +++ b/csharp/Euler/p0836.cs @@ -0,0 +1,28 @@ +/* +Project Euler Problem 836 + +Alright, this was funny + +Problem: + +Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + +We consider an **open oriented line section** U of A with normalized Haar measure m. + +Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the +**orthogonal kernel embedding** of U into A. + +Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. +*/ +using System; + +namespace Euler +{ + public class p0836 : IEuler + { + public Task Answer() + { + return Task.FromResult("aprilfoolsjoke"); + } + } +} diff --git a/csharp/README.rst b/csharp/README.rst index dacb4b8c..b6a4ddb0 100644 --- a/csharp/README.rst +++ b/csharp/README.rst @@ -84,4 +84,5 @@ Problems Solved - ☒ `9 <./p0009.cs>`__ - ☒ `11 <./p0011.cs>`__ - ☒ `17 <./p0017.cs>`__ +- ☒ `836 <./p0836.cs>`__ diff --git a/docs/c/p0836.rst b/docs/c/p0836.rst new file mode 100644 index 00000000..d708ac47 --- /dev/null +++ b/docs/c/p0836.rst @@ -0,0 +1,20 @@ +C Implementation of Problem 836 +=============================== + +View source code `here on GitHub! `_ + +Solution +-------- + +.. c:function:: char *p0836() + +.. c:function:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + +.. literalinclude:: ../../c/p0836.c + :language: C + :linenos: diff --git a/docs/cplusplus/p0836.rst b/docs/cplusplus/p0836.rst new file mode 100644 index 00000000..9a2f1a14 --- /dev/null +++ b/docs/cplusplus/p0836.rst @@ -0,0 +1,19 @@ +C++ Implementation of Problem 836 +================================= + +View source code `here on GitHub! `_ + +Solution +-------- + +.. cpp:function:: char *p0836() + +.. cpp:function:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + +.. literalinclude:: ../../cplusplus/p0836.cpp + :language: C++ + :linenos: diff --git a/docs/csharp.rst b/docs/csharp.rst index ea5ee9f3..5b2099b7 100644 --- a/docs/csharp.rst +++ b/docs/csharp.rst @@ -53,7 +53,7 @@ Test Infrastructure .. csharp:class:: Euler.IEuler - .. csharp:method:: Task Answer() + .. csharp:method:: Task Answer() .. csharp:namespace:: EulerTest diff --git a/docs/csharp/p0001.rst b/docs/csharp/p0001.rst index ef973d16..cf90ee7b 100644 --- a/docs/csharp/p0001.rst +++ b/docs/csharp/p0001.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0001.cs :language: csharp diff --git a/docs/csharp/p0002.rst b/docs/csharp/p0002.rst index a4b28bd8..73a1faf2 100644 --- a/docs/csharp/p0002.rst +++ b/docs/csharp/p0002.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0002.cs :language: csharp diff --git a/docs/csharp/p0004.rst b/docs/csharp/p0004.rst index 9faa2af6..670c51e7 100644 --- a/docs/csharp/p0004.rst +++ b/docs/csharp/p0004.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0004.cs :language: csharp diff --git a/docs/csharp/p0006.rst b/docs/csharp/p0006.rst index 45d53110..276248ac 100644 --- a/docs/csharp/p0006.rst +++ b/docs/csharp/p0006.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0006.cs :language: csharp diff --git a/docs/csharp/p0008.rst b/docs/csharp/p0008.rst index 75897f0a..b9c411c9 100644 --- a/docs/csharp/p0008.rst +++ b/docs/csharp/p0008.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0008.cs :language: csharp diff --git a/docs/csharp/p0009.rst b/docs/csharp/p0009.rst index 0e1b3311..261a0dc3 100644 --- a/docs/csharp/p0009.rst +++ b/docs/csharp/p0009.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0009.cs :language: csharp diff --git a/docs/csharp/p0011.rst b/docs/csharp/p0011.rst index ea5b95f5..f58a6f4c 100644 --- a/docs/csharp/p0011.rst +++ b/docs/csharp/p0011.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0011.cs :language: csharp diff --git a/docs/csharp/p0017.rst b/docs/csharp/p0017.rst index 622a1d8d..88bad731 100644 --- a/docs/csharp/p0017.rst +++ b/docs/csharp/p0017.rst @@ -9,7 +9,7 @@ View source code `here on GitHub! Answer() + .. csharp:method:: Task Answer() .. literalinclude:: ../../csharp/Euler/p0017.cs :language: csharp diff --git a/docs/csharp/p0836.rst b/docs/csharp/p0836.rst new file mode 100644 index 00000000..f9db61c9 --- /dev/null +++ b/docs/csharp/p0836.rst @@ -0,0 +1,16 @@ +C# Implementation of Problem 836 +================================ + +View source code `here on GitHub! `_ + +.. csharp:namespace:: Euler + +.. csharp:class:: p0836 + + .. csharp:inherits:: Euler.IEuler + + .. csharp:method:: Task Answer() + +.. literalinclude:: ../../csharp/Euler/p0836.cs + :language: csharp + :linenos: diff --git a/docs/index.rst b/docs/index.rst index 2f941b39..5f1eef8f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -270,6 +270,8 @@ Key: +-----------+------------+------------+------------+------------+------------+------------+ |:prob:`357`| | | | |:py-s:`0357`|:rs-i:`0357`| +-----------+------------+------------+------------+------------+------------+------------+ +|:prob:`836`|:c-d:`0836` |:cp-d:`0836`|:cs-d:`0836`|:js-d:`0836`|:py-d:`0836`|:rs-d:`0836`| ++-----------+------------+------------+------------+------------+------------+------------+ .. toctree:: :maxdepth: 2 diff --git a/docs/javascript/p0836.rst b/docs/javascript/p0836.rst new file mode 100644 index 00000000..9b70f958 --- /dev/null +++ b/docs/javascript/p0836.rst @@ -0,0 +1,10 @@ +JavaScript Implementation of Problem 836 +======================================== + +View source code `here on GitHub! `_ + +.. js:autofunction:: p0836 + +.. literalinclude:: ../../javascript/src/p0836.js + :language: javascript + :linenos: diff --git a/docs/python/p0836.rst b/docs/python/p0836.rst new file mode 100644 index 00000000..88ee0a99 --- /dev/null +++ b/docs/python/p0836.rst @@ -0,0 +1,22 @@ +Python Implementation of Problem 836 +==================================== + +View source code `here on GitHub! `_ + +Includes +-------- + +- `factors <./factors.html>`_ +- `primes <./primes.html>`_ + +Problem Solution +---------------- + +.. automodule:: python.p0836 + :members: + :undoc-members: + +.. literalinclude:: ../../python/p0836.py + :language: python + :linenos: + diff --git a/docs/rust/p0836.rst b/docs/rust/p0836.rst new file mode 100644 index 00000000..b3579be6 --- /dev/null +++ b/docs/rust/p0836.rst @@ -0,0 +1,13 @@ +Rust Implementation of Problem 836 +================================== + +View source code `here on GitHub! `_ + +Problem Solution +---------------- + +.. rust:fn:: p0836::p0836() -> i128 + +.. literalinclude:: ../../rust/src/p0836.rs + :language: rust + :linenos: diff --git a/javascript/README.rst b/javascript/README.rst index db8258b5..faefdb46 100644 --- a/javascript/README.rst +++ b/javascript/README.rst @@ -82,3 +82,4 @@ Problems Solved - ☒ `9 <./p0009.js>`__ - ☒ `11 <./p0011.js>`__ - ☒ `17 <./p0017.js>`__ +- ☒ `836 <./p0836.js>`__ diff --git a/javascript/euler.test.js b/javascript/euler.test.js index c7c59f1e..1a1be8c1 100644 --- a/javascript/euler.test.js +++ b/javascript/euler.test.js @@ -10,6 +10,7 @@ const answers = { 9: [require('./src/p0009.js'), 31875000], 11: [require('./src/p0011.js'), 70600674], 17: [require('./src/p0017.js'), 21124], + 836: [require('./src/p0836.js'), 'aprilfoolsjoke'], }; const knownSlow = []; let benchmarkReport = ''; diff --git a/javascript/src/p0836.js b/javascript/src/p0836.js new file mode 100644 index 00000000..29d1e539 --- /dev/null +++ b/javascript/src/p0836.js @@ -0,0 +1,22 @@ +/** + * + * Project Euler Problem 836 + * + * Alright, this was funny + * + * Problem: + * + * Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + * + * We consider an **open oriented line section** U of A with normalized Haar measure m. + * + * Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the + * **orthogonal kernel embedding** of U into A. + * + * Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. + * + * @return {string} + */ +exports.p0836 = function() { + return "aprilfoolsjoke"; +} diff --git a/python/README.rst b/python/README.rst index a228be4f..ddf0a07a 100644 --- a/python/README.rst +++ b/python/README.rst @@ -202,3 +202,4 @@ Problems Solved - ☒ `187 <./p0187.py>`__ - ☒ `206 <./p0206.py>`__ - ☒ `357 <./p0357.py>`__ +- ☒ `836 <./p0836.py>`__ diff --git a/python/p0836.py b/python/p0836.py new file mode 100644 index 00000000..16c356ad --- /dev/null +++ b/python/p0836.py @@ -0,0 +1,24 @@ +""" +Project Euler Problem 836 + +Alright, this was funny + +Problem: + +Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + +We consider an **open oriented line section** U of A with normalized Haar measure m. + +Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the +**orthogonal kernel embedding** of U into A. + +Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. +""" + + +def main() -> str: + return "aprilfoolsjoke" + + +if __name__ == '__main__': + print(main()) # pragma: no cover diff --git a/python/test_euler.py b/python/test_euler.py index f8acdbbe..7eb873cc 100644 --- a/python/test_euler.py +++ b/python/test_euler.py @@ -3,7 +3,7 @@ from pathlib import Path from shutil import which from sys import path -from typing import Any, Callable, Iterable, Tuple, Union, cast +from typing import Any, Callable, Dict, Iterable, Tuple, Union, cast from warnings import warn from pytest import fail, fixture, mark, skip, xfail @@ -15,7 +15,7 @@ from lib.iters import groupwise # noqa: E402 # isort:skip from lib.primes import is_prime, primes # noqa: E402 # isort:skip -answers = { +answers: Dict[int, Union[int, str]] = { 1: 233168, 2: 4613732, 3: 6857, @@ -94,6 +94,7 @@ 187: 17427258, 206: 1389019170, 357: 1739023853137, + 836: "aprilfoolsjoke", } known_slow = {118, 357} @@ -167,7 +168,7 @@ def func(set_of_primes: Iterable[int]) -> None: def test_problem(benchmark: Any, key: int) -> None: if (NO_SLOW and key in known_slow) or (ONLY_SLOW and key not in known_slow): skip() - test_func: Callable[[], int] = __import__("p{:0>4}".format(key)).main + test_func: Callable[[], Union[int, str]] = __import__("p{:0>4}".format(key)).main if key in known_slow: answer = benchmark.pedantic(test_func, iterations=1, rounds=1) else: diff --git a/rust/README.rst b/rust/README.rst index f557ca5c..16e33784 100644 --- a/rust/README.rst +++ b/rust/README.rst @@ -82,4 +82,5 @@ Problems Solved - ☒ `77 <./src/p0077.rs>`__ - ☒ `87 <./src/p0087.rs>`__ - ☒ `357 <./src/p0357.rs>`__ +- ☒ `836 <./src/p0836.rs>`__ diff --git a/rust/src/main.rs b/rust/src/main.rs index e49821e8..eb262df8 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -56,6 +56,7 @@ fn get_problem<'b>(n: u32) -> ProblemRef<'b> { 77 => ( &77, p0077::p0077, 71), 87 => ( &87, p0087::p0087, 1097343), 357 => (&357, p0357::p0357, 1739023853137), + 836 => (&836, p0836::p0836, i128::from_ne_bytes(*b"\x00\x00aprilfoolsjoke")), _ => panic!(), }; } diff --git a/rust/src/p0836.rs b/rust/src/p0836.rs new file mode 100644 index 00000000..f736b032 --- /dev/null +++ b/rust/src/p0836.rs @@ -0,0 +1,20 @@ +/* +Project Euler Problem 836 + +Alright, this was funny + +Problem: + +Let A be an **affine plane** over a **radically integral local field** F with residual characteristic p. + +We consider an **open oriented line section** U of A with normalized Haar measure m. + +Define f(m,p) as the maximal possible discriminant of the **jacobian** associated to the +**orthogonal kernel embedding** of U into A. + +Find f(20230401, 57). Give as your answer the concatenation of the first letters of each bolded word. +*/ + +pub fn p0836() -> i128 { + return i128::from_ne_bytes(*b"\x00\x00aprilfoolsjoke"); +}