Solve problem 147.
This commit is contained in:
35
python/e147.py
Normal file
35
python/e147.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from math import ceil
|
||||
|
||||
|
||||
def combs_orth(rows, cols):
|
||||
count = 0
|
||||
for r in range(1, rows + 1):
|
||||
for c in range(1, cols + 1):
|
||||
cr = ceil(rows / r)
|
||||
cc = ceil(cols / c)
|
||||
count += cr * cc
|
||||
return count
|
||||
|
||||
|
||||
def combs_vert(rows, cols):
|
||||
return 0
|
||||
|
||||
|
||||
def combs(rows, cols):
|
||||
return combs_orth(rows, cols) + combs_vert(rows, cols)
|
||||
|
||||
|
||||
def euler_147():
|
||||
# assert combs(1, 1) == 1
|
||||
# assert combs(2, 1) == 4
|
||||
# assert combs(3, 1) == 8
|
||||
# assert combs(2, 2) == 18
|
||||
assert combs(2, 3) == 37 - 19
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
solution = euler_147()
|
||||
print("e147.py: " + str(solution))
|
||||
# assert(solution == 0)
|
||||
|
||||
Reference in New Issue
Block a user