Skip to content

Commit ef53bbd

Browse files
authored
Style Improvements for project_euler/problem_26 (#2958)
* add typehints and docstrings * add typehint and default value * add typehint and default value. Removed unused variable. * do not modifiy the given solution * add doctests * update sol1 after running black * add typehint, docstring, and doctest * update sol2 after running black * add full problem statement and solution function with typehint and doctest * renamed original function instead of adding new one * don't alter original solution
1 parent 6a5a022 commit ef53bbd

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Diff for: project_euler/problem_26/sol1.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
"""
22
Euler Problem 26
33
https://projecteuler.net/problem=26
4+
5+
Problem Statement:
6+
7+
A unit fraction contains 1 in the numerator. The decimal representation of the
8+
unit fractions with denominators 2 to 10 are given:
9+
10+
1/2 = 0.5
11+
1/3 = 0.(3)
12+
1/4 = 0.25
13+
1/5 = 0.2
14+
1/6 = 0.1(6)
15+
1/7 = 0.(142857)
16+
1/8 = 0.125
17+
1/9 = 0.(1)
18+
1/10 = 0.1
19+
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be
20+
seen that 1/7 has a 6-digit recurring cycle.
21+
422
Find the value of d < 1000 for which 1/d contains the longest recurring cycle
523
in its decimal fraction part.
624
"""
725

826

9-
def find_digit(numerator: int, digit: int) -> int:
27+
def solution(numerator: int = 1, digit: int = 1000) -> int:
1028
"""
1129
Considering any range can be provided,
1230
because as per the problem, the digit d < 1000
13-
>>> find_digit(1, 10)
31+
>>> solution(1, 10)
1432
7
15-
>>> find_digit(10, 100)
33+
>>> solution(10, 100)
1634
97
17-
>>> find_digit(10, 1000)
35+
>>> solution(10, 1000)
1836
983
1937
"""
2038
the_digit = 1

0 commit comments

Comments
 (0)