find the min cost of tiles to cover a floor floor is represented by 2d array where tile already placed no tile tiles available are 11 and 12 and their costs are a and b source https www geeksforgeeks orgminimizecosttocoverfloorusingtilesofdimensions11and12 tile is already there if j is pointing to last tile you can use only 1 1 tile
def cost(arr, A, B):
    n = len(arr)
    m = len(arr[0])

    ans = 0

    for i in range(n):
        j = 0
        
        while j < m:
            if arr[i][j] == '*':  
                j += 1
                continue

            if j == m - 1:  
                ans += A
            else:
                if arr[i][j+1] == '.':
                    ans += min(2 * A, B)
                    j += 1
                else:
                    ans += A

            j += 1

    print('Cost of tiling is - ', ans)

arr = [ [ '.', '.', '*' ],
        [ '.', '*', '*' ] ]

A, B = 2, 10

cost(arr, A, B)