Fill the Grid with three colors A, B and C

Revision en1, by algorithms400, 2018-02-22 16:03:00

How to find the numbers of ways to fill a grid (3*n)array, with three colors A, B and C.

Under the following constraints:

1) All the n cells of the same row can't have the same color.

2) All the 3 cells of the same column can't have the same color.

Sample input : if n=2, then output or number of ways = 174.

Please explain the approach for this.

Tags 2d-dp, #algorithms, #combinatorics, #matrix

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English algorithms400 2018-02-22 16:03:00 411 Initial revision (published)