As far as I can see, the strategy is to place L so that it occupies exactly one cube in three squares, which does not contain an already occupied cube.
In other words:
- you split the input square into 4 squares.
- One of them already has a busy cube.
- You place L so that the 3 other squares end with exactly one occupied cube.
Therefore, now you have 4 squares - all with one cube occupied. So now you can run the function on these four squares.

Now you can process each of the 4 squares independently, since each square has exactly one occupied cube.
What is the problem with your code?
The problem is that you are not updating the position of the occupied cube, but simply maintaining the original position.
// top-right sub-partion recursiveSolve(m, A, A_row, A_colCenter, t_row, t_col, ++currBlockNum, A_halfSize); ^^^^^^^^^^^^ May need update before calling // bottom-right sub-partion recursiveSolve(m, A, A_rowCenter, A_colCenter, t_row, t_col, ++currBlockNum, A_halfSize); ^^^^^^^^^^^^ May need update before calling // bottom left sub-partition recursiveSolve(m, A, A_rowCenter, A_col, t_row, t_col, ++currBlockNum, A_halfSize); ^^^^^^^^^^^^ May need update before calling // top-left sub-partition recursiveSolve(m, A, A_row, A_col, t_row, t_col, ++currBlockNum, A_halfSize); ^^^^^^^^^^^^ May need update before calling
For 3 out of 4 calls, you need to update the position of the occupied square.
This can be achieved in many ways. Here is one approach:
void recursiveSolve(int m, int A[m][m], int A_row, int A_col, int t_row, int t_col, int currBlockNum, int boardSize) { if (boardSize == 2) { // Keep your existing code unchanged here } else { int A_halfSize = boardSize / 2; // the bellow calculations allow us to check which // sub-partition of our board includes the missing block, // as well as how we should paint the center L shaped block. int A_rowCenter = A_row + A_halfSize; int A_colCenter = A_col + A_halfSize; // Calculate the position of the center cubes // as these will be the new occupied cub for // 3 of the 4 squares int TR_t_row = A_rowCenter - 1; int TR_t_col = A_colCenter; int BR_t_row = A_rowCenter; int BR_t_col = A_colCenter - 1; int BL_t_row = A_rowCenter - 1; int BL_t_col = A_colCenter; int TL_t_row = A_rowCenter - 1; int TL_t_col = A_colCenter - 1; if (t_row < A_rowCenter) { // missing block in top half if (t_col < A_colCenter ) { // missing block is in top left half A[A_rowCenter][A_colCenter-1] = currBlockNum; A[A_rowCenter][A_colCenter] = currBlockNum; A[A_rowCenter-1][A_colCenter] = currBlockNum; TL_t_row = t_row; // Roll back to TL_t_col = t_col; // original occupied cube } else { // missing block is in top right half A[A_rowCenter-1][A_colCenter-1] = currBlockNum; A[A_rowCenter][A_colCenter-1] = currBlockNum; A[A_rowCenter][A_colCenter] = currBlockNum; TR_t_row = t_row; // Roll back TR_t_col = t_col; } } else { // missing block in bottom half if (t_col < A_colCenter ) { // missing block is in bottom left half A[A_rowCenter][A_colCenter] = currBlockNum; A[A_rowCenter-1][A_colCenter] = currBlockNum; A[A_rowCenter-1][A_colCenter-1] = currBlockNum; BL_t_row = t_row; // Roll back BL_t_col = t_col; } else { // missing block is in bottom right half A[A_rowCenter][A_colCenter-1] = currBlockNum; A[A_rowCenter-1][A_colCenter-1] = currBlockNum; A[A_rowCenter-1][A_colCenter] = currBlockNum; BR_t_row = t_row; // Roll back BR_t_col = t_col; } } // solve each sub-partion recursively // Use the 8 new variables for the recursive calls // top-right sub-partion recursiveSolve(m, A, A_row, A_colCenter, TR_t_row, TR_t_col, ++currBlockNum, A_halfSize); // ^^^^^^^^^^^^^^^^^^ // bottom-right sub-partion recursiveSolve(m, A, A_rowCenter, A_colCenter, BR_t_row, BR_t_col, ++currBlockNum, A_halfSize); // ^^^^^^^^^^^^^^^^^^ // bottom left sub-partition recursiveSolve(m, A, A_rowCenter, A_col, BL_t_row, BL_t_col, ++currBlockNum, A_halfSize); // ^^^^^^^^^^^^^^^^^^ // top-left sub-partition recursiveSolve(m, A, A_row, A_col, TL_t_row, TL_t_col, ++currBlockNum, A_halfSize); // ^^^^^^^^^^^^^^^^^^ } }
Update
If you want to avoid using the same number for multiple currBlockNum , you should instead pass a pointer to currBlockNum .
Change the prototype - pay attention to int* currBlockNum :
void recursiveSolve(int m, int A[m][m], int A_row, int A_col, int t_row, int t_y, int* currBlockNum, int boardSize);
Basically do:
int currBlockNum = 1; recursiveSolve(m, A, 0, 0, t_row, t_col, &currBlockNum, m); ^^^ Notice
In the change all function, the place where you want to assign a value - for example
A[A_row+1][A_col] = *currBlockNum; ^^^ Notice
and each time you call the function recursively, first increment it - for example:
++(*currBlockNum); recursiveSolve(m, A, A_row, A_colCenter, TR_t_row, TR_t_col, currBlockNum, A_halfSize);