I would like to generate a text file containing all 19,683 Tic-Tac-Toe board layouts in the structure of 0 = Blank, 1 = X, and 2 = O. Unfortunately math is not my strong su
There are 9 positions and an alphabet with 3 letters (X, O, empty). Total number of possible combinations is 3^9 = 19683.
for(int i = 0; i < 19683; ++i) { int c = i; for (int j = 0; j < 9; ++j) { cout << (c % 3) << " "; c /= 3; } cout << endl; }