If consecutive ' . ' are present , the greedily choose tile with the minimum cost
else : NEW_LINE INDENT if ( arr [ i ] [ j + 1 ] == ' . ' ) : NEW_LINE INDENT ans += min ( 2 * A , B ) NEW_LINE j += 1 NEW_LINE DEDENT DEDENT