project euler problem 117 https projecteuler netproblem117 using a combination of grey square tiles and oblong tiles chosen from red tiles measuring two units green tiles measuring three units and blue tiles measuring four units it is possible to tile a row measuring five units in length in exactly fifteen different ways greygreygreygreygrey red redgreygreygrey greyred redgreygrey greygreyred redgrey greygreygreyred red red redred redgrey red redgreyred red greyred redred red green green greengreygrey greygreen green greengrey greygreygreen green green red redgreen green green green green greenred red blue blue blue bluegrey greyblue blue blue blue how many ways can a row measuring fifty units in length be tiled note this is related to problem 116 https projecteuler netproblem116 returns the number of ways can a row of the given length be tiled solution5 15 returns the number of ways can a row of the given length be tiled solution 5 15
def solution(length: int = 50) -> int:
    

    ways_number = [1] * (length + 1)

    for row_length in range(length + 1):
        for tile_length in range(2, 5):
            for tile_start in range(row_length - tile_length + 1):
                ways_number[row_length] += ways_number[
                    row_length - tile_start - tile_length
                ]

    return ways_number[length]


if __name__ == "__main__":
    print(f"{solution() = }")