# Java domino tiling with recursion: second if block gets called with already updated values

A rectangular grid m x n, should be filled with m*n/2 2x1 dominoes that can be placed horizontally or vertically. How many possible soluitons exist?

I'm trying to solve this problem with recursion (yes I know that this can easily be calculated with fibonacci).

private static void place(int row, int col, int[][] rectangle) {

if (canBePlacedHorizontally(row, col, rectangle)) {

rectangle = deepCopy(rectangle);

placeHorizontally(row, col, rectangle);

decideNextMove(row, col, rectangle);

}

if (canBePlacedVertically(row, col, rectangle)) {

rectangle = deepCopy(rectangle);

placeVertically(row, col, rectangle);

decideNextMove(row, col, rectangle);

}

}

private static void decideNextMove(int row, int col, int[][] rectangle) {

if (rectangleIsFilled(rectangle)) {

count = count.add(BigInteger.ONE);

}

else if(row == rectangle.length -1) {

place(0,...

By: StackOverFlow - Monday, 17 September

# Related Posts

- Older News
- permutations of k enums of length n without recursion StackOverFlow (Today) - Given enums: enum MyType { Red, Green, Blue, …, LastColor };and a function for unit testing.enum MyType { Red, Green, Blue, …, LastColor };// Assume K enumsAssume a function like...
- What is the best way to store data in android app, that will not be updated by the user? StackOverFlow (2 days ago) - I am making an activity where the user inputs their weight into an EditText field. Based on the value they write, a GridView with around 20 numeric values will be...