Skip to content

Commit 1ca8388

Browse files
Update sol4.py
1 parent 59a0765 commit 1ca8388

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

project_euler/problem_009/sol4.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@
55
66
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
77
8-
a^2 + b^2 = c^2
8+
a^2 + b^2 = c^2.
99
1010
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
1111
1212
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
13-
Find the product a*b*c.
13+
Find the product abc.
1414
1515
References:
1616
- https://en.wikipedia.org/wiki/Pythagorean_triple
1717
"""
1818

1919

2020
def get_squares(n: int) -> list[int]:
21-
res = [0] * n
22-
for i in range(n):
23-
res[i] = i * i
24-
return res
21+
"""
22+
>>> get_squares(0)
23+
[]
24+
>>> get_squares(1)
25+
[0]
26+
>>> get_squares(2)
27+
[0, 1]
28+
>>> get_squares(3)
29+
[0, 1, 4]
30+
>>> get_squares(4)
31+
[0, 1, 4, 9]
32+
"""
33+
return [number * number for number in range(n)]
2534

2635

2736
def solution(n: int = 1000) -> int:

0 commit comments

Comments
 (0)