Coloring the blocks There are n blocks placed in a row. Each block must be covered with one of the

Coloring the blocks
There are n blocks placed in a row. Each block must be covered with one of the three colors available, b no two adjacent blocks can be the same color. The cost of coloring each block varies and is given in an array. Given the cost of using each color on each block, determine the minimum cost to color all of the blocks.

example.
cost = [[1,2,3],
[1,2,3],
[3,3,1],]

For the first block, the cheapest color is the first co which costs 1. For the second block, colors cost the same but color 1 cannot be used because it match the first block. Instead, choose color 2. For the thir block, it can be color 1 or color 3. The cheaper is color 3 at 1 unit. The total cost to color the blocks i + 2 + 1 = 4.
Write a program that takes input in the below give format and prints output in the below given forma
Constraints
• 1_<n <100
. 0
<cost[i] [j]_<100​

Comments (2)