Returns the number of ways can a row of the given length be tiled >>> solution(5) 15
(length: int = 50)
| 30 | |
| 31 | |
| 32 | def 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 | |
| 52 | if __name__ == "__main__": |