Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in basic python please! thank you! Introduction Tic-tac-toe is a game for two players, X and o, who take turns marking the spaces in a

in basic python please! thank you!
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Introduction Tic-tac-toe is a game for two players, X and o, who take turns marking the spaces in a 3 x 3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical or diagonal row wins the game. The following example game is won by the first player, X: A ON 4 x H You have been hired by CoolGames, Inc. to create a tic-tac-toe checker program that they can use to determine whether X wins, O wins, or if a tie has resulted. Program Input The first line of the file xcred.txt will contain a positive integer T denoting the number of test cases that follow. Each test case will have the following input: . A single line of characters denoting the current state of a Tic-Tac Toe game The game state will be represented as follows: c6 VALUE> 1 2. 2 3 0 X X 4 5 6 o 0 123456789 0-- 7 8 00 9 XX Figure 1. Tic-Tac Toe Mapping Figure 2. Tic-Tac Toe Game Figure 3. Tic-Tac-Toe Encoding In Figure 1, it shows how the values in the tic-tac-toe board are mapped. In Figure 2, it shows an example tic-tac-toe game being played where "-" means no one has played in the area. In Figure 3, it shows how the tic-tac-toe game is encoded into a string of values based on the board mapping. Example Input: 8 O-X-OOXXX XOX-OXO-X X-O-XO--O OXOXXOXOX --X-X-X00 XXOXO-0-- XOXXOOOXX Program Output For each test case, your program should output one line in the following format: The original input line followed by a single space, an equal sign, and another single spa One of the following three phrases depending on the outcome of the game: X WINS O WINS TIE o O o Example Output: 0-X-OOXXX = X WINS XOX-OXO-X = X WINS X-O-XO--O O WINS OXOXXOXOX = TIE --X-X-XOO = X WINS XXOXO-0--- O WINS XOXXOOOXX - TIE = TIE Lab+2C - Notepad . File Edit Format View 8 0-X-OOXXX XOX-OXO-X X-0-X0--0 OXOXXOXOX --X-X-XOO XXOXO-0-- XOXXOOOXX

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions