Statistics

Problem Statement for "DominoTiling"

Problem Statement

You are given a String[] grid that describes a rectangular grid of square cells. The character 'X' represents a cell that is already covered, the character '.' is a cell that still needs to be covered.

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

  1. {"..", ".."}

    Returns: 2

    There are exactly two ways to do this: -- or || -- ||

  2. {"...", ".X.", "..."}

    Returns: 2

    Again, there are two solutions: --| |-- |X| |X| |-- --|

  3. {"...", "...", "..X"}

    Returns: 4

    ||| --| |-- --| ||| --| |-- ||| --X __X --X ||X

  4. {".....", ".....", ".X...", ".X..."}

    Returns: 29

  5. {"..","..",".."}

    Returns: 3

  6. {"............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............"}

    Returns: 53060477521960000

  7. {".........."}

    Returns: 1

  8. {".XX.XX.....X"}

    Returns: 0

  9. {"......","....X.","....X."}

    Returns: 11

  10. {"..XX","XX..","..XX","XX..","XX..","....","XX..","XXXX","....","....","....","XX.."}

    Returns: 90

  11. {"XX..XX....","....XX..XX","XXXX..XX..","XX..XX..XX"}

    Returns: 4

  12. {"........","........"}

    Returns: 34

  13. {"XX........","XX..XX..XX","....XX....","..XXXXXXXX","......XX..","..........","......XXXX","..XXXX..XX","....XX..XX","XXXXXXXX..","..XX......","..XX......"}

    Returns: 361584

  14. {"XXXX......","XX........","..XX......","XXXX......","XX..XX..XX","XX..XX....","..XX......","..XX..XX..","..XXXX..XX","....XX..XX","..XX....XX","..XX..XX.."}

    Returns: 1116960

  15. {"..XX....","..XX..XX"}

    Returns: 4

  16. {".XX.........", "............", "............", "............", "XX..........", "............", "........XX..", "........XX..", "..XX.X......", ".....X......", "............", "............" }

    Returns: 49574223766540

  17. {"............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............", "............" }

    Returns: 53060477521960000


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: