Skip to content

Commit c7f58df

Browse files
committed
Use functools.reduce()
1 parent 0b8f87a commit c7f58df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/euler/bin/p0040.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# ...
1313
# block #n: n-digits number
1414

15+
from functools import reduce
16+
from operator import mul
1517
from typing import cast
1618

1719

@@ -39,7 +41,7 @@ def d(pos: int) -> int:
3941

4042

4143
def compute() -> str:
42-
return str(d(1) * d(10) * d(100) * d(1_000) * d(10_000) * d(100_000) * d(1_000_000))
44+
return str(reduce(mul, map(d, [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000])))
4345

4446

4547
def solve() -> str:

0 commit comments

Comments
 (0)