MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_114/sol1.py:35–54  ·  view source on GitHub ↗

Returns the number of ways a row of the given length can be filled >>> solution(7) 17

(length: int = 50)

Source from the content-addressed store, hash-verified

33
34
35def solution(length: int = 50) -> int:
36 """
37 Returns the number of ways a row of the given length can be filled
38
39 >>> solution(7)
40 17
41 """
42
43 ways_number = [1] * (length + 1)
44
45 for row_length in range(3, length + 1):
46 for block_length in range(3, row_length + 1):
47 for block_start in range(row_length - block_length):
48 ways_number[row_length] += ways_number[
49 row_length - block_start - block_length - 1
50 ]
51
52 ways_number[row_length] += 1
53
54 return ways_number[length]
55
56
57if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected