Use second parameter n to inidicate colors number.

So this solution can support not only three colors.

```
class Solution:
# @param {integer[][]} costs
# @return {integer}
def minCost(self, costs, n=3):
tmp = [0] * n
for i in costs: tmp = [i[j] + min((tmp[j:]+tmp[0:j])[1:]) for j in range(n)]
return min(tmp)
```

UPDATE, thanks for @StefanPochmann:

```
class Solution:
# @param {integer[][]} costs
# @return {integer}
def minCost(self, costs, n=3):
tmp = [0] * n
for i in costs:
tmp = [i[j] + min(tmp[j+1:]+tmp[0:j]) for j in range(n)]
return min(tmp)
```

UPDATE, 1 line solution:

```
class Solution:
# @param {integer[][]} costs
# @return {integer}
def minCost(self, costs, n=3):
return min(reduce(lambda x, y: [y[i] + min(x[i+1:]+x[0:i]) for i in range(n)], costs, [0]*n))
```