[Project Euler] Fix code style for multiple problems (#3094)

* Fix code style for Project Euler problems:

- 13, 17, 21
- Default args
- Type hints
- File path

* Fix code style for multiple problems

* Made suggested changes
This commit is contained in:
Dhruv
2020-10-10 21:23:17 +05:30
committed by GitHub
parent c961d5541f
commit 501a2ff430
11 changed files with 89 additions and 67 deletions

View File

@ -1,4 +1,6 @@
"""
Problem 44: https://projecteuler.net/problem=44
Pentagonal numbers are generated by the formula, Pn=n(3n1)/2. The first ten
pentagonal numbers are:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...
@ -24,11 +26,11 @@ def is_pentagonal(n: int) -> bool:
return ((1 + root) / 6) % 1 == 0
def compute_num(limit: int = 5000) -> int:
def solution(limit: int = 5000) -> int:
"""
Returns the minimum difference of two pentagonal numbers P1 and P2 such that
P1 + P2 is pentagonal and P2 - P1 is pentagonal.
>>> compute_num(5000)
>>> solution(5000)
5482660
"""
pentagonal_nums = [(i * (3 * i - 1)) // 2 for i in range(1, limit)]
@ -42,4 +44,4 @@ def compute_num(limit: int = 5000) -> int:
if __name__ == "__main__":
print(f"{compute_num() = }")
print(f"{solution() = }")