Problem Statement
You are given a
You want to cover all the '.' cells using a collection of disjoint 2x1 dominos. Return the number of ways to do this. Two ways are considered different if two cells are covered by the same domino in one tiling and by two different dominos in the other tiling.
Definition
- Class:
- DominoTiling
- Method:
- count
- Parameters:
- String[]
- Returns:
- long
- Method signature:
- long count(String[] grid)
- (be sure your method is public)
Constraints
- grid will contain between 1 and 12 elements, inclusive.
- The length of each element of grid will be between 1 and 12, inclusive.
- Each element of grid will be the same length.
- Each character of each element of grid will be '.' or 'X'.
Examples
{"..", ".."}
Returns: 2
There are exactly two ways to do this: -- or || -- ||
{"...", ".X.", "..."}
Returns: 2
Again, there are two solutions: --| |-- |X| |X| |-- --|
{"...", "...", "..X"}
Returns: 4
||| --| |-- --| ||| --| |-- ||| --X __X --X ||X
{".....", ".....", ".X...", ".X..."}
Returns: 29
{"..","..",".."}
Returns: 3
{"............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............"}
Returns: 53060477521960000
{".........."}
Returns: 1
{".XX.XX.....X"}
Returns: 0
{"......","....X.","....X."}
Returns: 11
{"..XX","XX..","..XX","XX..","XX..","....","XX..","XXXX","....","....","....","XX.."}
Returns: 90
{"XX..XX....","....XX..XX","XXXX..XX..","XX..XX..XX"}
Returns: 4
{"........","........"}
Returns: 34
{"XX........","XX..XX..XX","....XX....","..XXXXXXXX","......XX..","..........","......XXXX","..XXXX..XX","....XX..XX","XXXXXXXX..","..XX......","..XX......"}
Returns: 361584
{"XXXX......","XX........","..XX......","XXXX......","XX..XX..XX","XX..XX....","..XX......","..XX..XX..","..XXXX..XX","....XX..XX","..XX....XX","..XX..XX.."}
Returns: 1116960
{"..XX....","..XX..XX"}
Returns: 4
{".XX.........", "............", "............", "............", "XX..........", "............", "........XX..", "........XX..", "..XX.X......", ".....X......", "............", "............" }
Returns: 49574223766540
{"............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............" }
Returns: 53060477521960000