diff --git a/README.rst b/README.rst index 6e04889b..616c0c45 100644 --- a/README.rst +++ b/README.rst @@ -57,7 +57,7 @@ LivInTheLookingGlass’s Project Euler solutions | | | | |CodeQL| |br| | | | | | |ESLint| | +------------+-------------------------+--------+-------------------+ -| Python | CPython 3.6+ |br| | 77 | |Python| |br| | +| Python | CPython 3.6+ |br| | 78 | |Python| |br| | | | Pypy 3.6+ |br| | | |Py-Cov| |br| | | | GraalPy 23.1+ | | |CodeQL| |br| | | | | | |PythonLint| | diff --git a/docs/index.rst b/docs/index.rst index be36652a..2f941b39 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -228,6 +228,8 @@ Key: +-----------+------------+------------+------------+------------+------------+------------+ |:prob:`60` | | | | |:py-d:`0060`| | +-----------+------------+------------+------------+------------+------------+------------+ +|:prob:`63` | | | | |:py-d:`0063`| | ++-----------+------------+------------+------------+------------+------------+------------+ |:prob:`67` | | | | |:py-d:`0067`| | +-----------+------------+------------+------------+------------+------------+------------+ |:prob:`69` | | | | |:py-d:`0069`| | diff --git a/docs/python/p0063.rst b/docs/python/p0063.rst new file mode 100644 index 00000000..aa384401 --- /dev/null +++ b/docs/python/p0063.rst @@ -0,0 +1,16 @@ +Python Implementation of Problem 63 +=================================== + +View source code `here on GitHub! `_ + +Problem Solution +---------------- + +.. automodule:: python.p0063 + :members: + :undoc-members: + +.. literalinclude:: ../../python/p0063.py + :language: python + :linenos: + diff --git a/python/p0063.py b/python/p0063.py new file mode 100644 index 00000000..5a4fe7bc --- /dev/null +++ b/python/p0063.py @@ -0,0 +1,24 @@ +""" +Project Euler Problem 63 + +Problem: + +The 5-digit number, 16807 = 7**5, is also a fifth power. +Similarly, the 9-digit number, 134217728 = 8**9, is a ninth power. + +How many n-digit positive integers exist which are also an nth power? +""" +from typing import Dict, Tuple + + +def main() -> int: + seen: Dict[Tuple[int, int], int] = {} + for x in range(1, 10): + for n in range(1, 100): + if len(str(x**n)) == n: + seen[x,n] = x**n + return len(seen) + + +if __name__ == '__main__': + print(main()) # pragma: no cover diff --git a/python/test_euler.py b/python/test_euler.py index 26782505..f8acdbbe 100644 --- a/python/test_euler.py +++ b/python/test_euler.py @@ -74,6 +74,7 @@ 59: 107359, 60: 26033, 67: 7273, + 63: 49, 69: 510510, 71: 428570, 73: 7295372,