Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How do i generate random numbers that are a valid sudoku board?

$
0
0
I have the board set up, but I dont know how to place random, but also valid numbers in the board.

void display_board()
{
    const int SCREEN_NUM_ROW = 20;

    const char GONE_FILL = 'X';
    
    string screen_board[SCREEN_NUM_ROW];
    screen_board[0] =  "   | A   B   C | D   E   F | G   H   I |";
    screen_board[1] =  " ---------------------------------------";
    screen_board[2] =  " 1 |   /   /   |   /   /   |   /   /   |";
    screen_board[3] =  "   -------------------------------------";
    screen_board[4] =  " 2 |   /   /   |   /   /   |   /   /   |";
    screen_board[5] =  "   -------------------------------------";
    screen_board[6] =  " 3 |   /   /   |   /   /   |   /   /   |";
    screen_board[7] =  " ---___________-___________-___________-";
    screen_board[8] =  " 4 |   /   /   |   /   /   |   /   /   |";
    screen_board[9] =  "   -------------------------------------";
    screen_board[10] = " 5 |   /   /   |   /   /   |   /   /   |";
    screen_board[11] = "   -------------------------------------";
    screen_board[12] = " 6 |   /   /   |   /   /   |   /   /   |";
    screen_board[13] = " ---___________-___________-___________-";
    screen_board[14] = " 7 |   /   /   |   /   /   |   /   /   |";
    screen_board[15] = "   -------------------------------------";
    screen_board[16] = " 8 |   /   /   |   /   /   |   /   /   |";
    screen_board[17] = "   -------------------------------------";
    screen_board[18] = " 9 |   /   /   |   /   /   |   /   /   |";
    screen_board[19] = " ---___________-___________-___________-";
    screen_board[20] = "                                        ";



that's my board.

don't mind the "GONE_FILL .. " etc. .. that's not supposed to be there (:

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>