Skip to content

Commit

Permalink
solve p63 in python
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 29, 2024
1 parent 66f9365 commit 8c8f25d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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| |
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`| |
Expand Down
16 changes: 16 additions & 0 deletions docs/python/p0063.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Python Implementation of Problem 63
===================================

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0063.py>`_

Problem Solution
----------------

.. automodule:: python.p0063
:members:
:undoc-members:

.. literalinclude:: ../../python/p0063.py
:language: python
:linenos:

24 changes: 24 additions & 0 deletions python/p0063.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions python/test_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
59: 107359,
60: 26033,
67: 7273,
63: 49,
69: 510510,
71: 428570,
73: 7295372,
Expand Down

0 comments on commit 8c8f25d

Please sign in to comment.