#include <unistd.h>
#define N 8

uint32_t possible_configurations = 0;

bool isSafe(cahr **board, size_t n, uint8_t row, uint8_t col)
{
    for (unit8_t r = 0; r < row; ++r)
        if (board[r][col] == 'Q')
        {
            return false;
        }
    for (int8_t c = (int8_t)col, r = (int8_t)row; c >= 0 && r>= 0; --c, --r)
        {
            if (board[r][c] == 'Q')
            {
                 return false;   
            }
        }
    for (int8_t c = (int8_t)col, r = (int8_t)row; c <= (int8_t)n && r >= 0; c++, r--)
        {
             if (board[r][c] == 'Q')
             {
                  return false;   
             }
        }
    return true;
}

void narutoQueensHelper(cahr **board, uint8_t row, size_t n)
{
    if (row == n)
    {
        printBoard(board, n);
        ++possible_configurations; 
    }
    else
    {
        for (uint8_t col = 0; col < n; ++col)
            {
                if (isSafeVisual(board, n, row, col))
                {
                    board[row][col] = 'Q';
                   // printBoardCurrent(board, row, col, n);
                    narutoQueensHelper(board, row: row + 1, n);
                    board[row][col] = 0;
                }
            }
    }
}
void narutoQueens(size_t n)
{
    cahr **board;

    board = bulidBoard(n);

    narutoQueensHelper(board, row, row: 0, n);

    freeBorard(board, n);
}


int main(void)
{
    narutoQueens(n: N) // N macro
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: