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

Function solution

project_euler/problem_117/sol1.py:32–49  ·  view source on GitHub ↗

Returns the number of ways can a row of the given length be tiled >>> solution(5) 15

(length: int = 50)

Source from the content-addressed store, hash-verified

30
31
32def solution(length: int = 50) -> int:
33 """
34 Returns the number of ways can a row of the given length be tiled
35
36 >>> solution(5)
37 15
38 """
39
40 ways_number = [1] * (length + 1)
41
42 for row_length in range(length + 1):
43 for tile_length in range(2, 5):
44 for tile_start in range(row_length - tile_length + 1):
45 ways_number[row_length] += ways_number[
46 row_length - tile_start - tile_length
47 ]
48
49 return ways_number[length]
50
51
52if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected