208k views
1 vote
The game of 3D Tic-Tac-Toe is played on a 4x4x4 cube of cells. As in ordinary Tic-Tac-Toe, players take turn placing marks X or O. The winner is the first player to form four in a row in any direction. Write a program in C# that reads a board position of 3D Tic-Tac-Toe. Each of the four levels of the board will be represented by four input lines. Each of those lines will contain four characters, each of which will be a lowercase 'x' or 'o', or '.' for an empty space. Levels will be separated by a blank line. The program should determine who has won the game, if anyone. If either player has won, the program should copy the board to standard output, indicating the winning four cells with capital X or O characters. If neither player has won, the program should print a single output line with the text 'no winner'. (It is guaranteed that there will be at most one winning line of four marks.)

User Zac Lozano
by
8.2k points

1 Answer

0 votes

Final answer:

The program should check all possible winning combinations on the 4x4x4 3D Tic-Tac-Toe board and determine the winner.

Step-by-step explanation:

The problem can be solved by checking all possible winning combinations in each direction (vertical, horizontal, diagonal, and 3D diagonal) on the 4x4x4 board. This can be done by iterating through each cell and checking if there is a winning combination starting from that cell. The program should keep track of the player who has formed four in a row and mark the winning cells with capital X or O. If no player has won, the program should print 'no winner'.

User Adam Asham
by
6.6k points