forked from Tecmax/JavaAndroidPractise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp076.py
More file actions
31 lines (26 loc) · 649 Bytes
/
Copy pathp076.py
File metadata and controls
31 lines (26 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# Solution to Project Euler problem 76
# Copyright (c) Project Nayuki. All rights reserved.
#
# https://www.nayuki.io/page/project-euler-solutions
# https://github.com/nayuki/Project-Euler-solutions
#
def compute():
LIMIT = 100
partitions = []
for i in range(LIMIT + 1):
partitions.append([None] * (LIMIT + 1))
for j in reversed(range(LIMIT + 1)):
if j == i:
val = 1
elif j > i:
val = 0
elif j == 0:
val = partitions[i][j + 1]
else:
val = partitions[i][j + 1] + partitions[i - j][j]
partitions[i][j] = val
ans = partitions[LIMIT][1] - 1
return str(ans)
if __name__ == "__main__":
print(compute())