Answer to Question #340209 in Python for Lingaraju

Question #340209

Tic Tac Toe -2

Ravans dream in to win the Tic Tac Toe campionship to accomplish this he practices alone at home to learn the strategies the game .your tast is to identify the cell where Ravan should place the third piece so that the wins the game Assume the each cell in the tic tac toe board in marked a number as shown in the table below


Tic Tac Toe


0 1 2

3 4 5

6 7 8


input


the first line of input contains space-seperated integers representing the cells where Ravan his first two pieces


output

the output should be single integers representing cell where Ravanshould places his final place

sample input 1

0 1

sample output 1

2

sample output 2

0 3

sample output 2

6



1
Expert's answer
2022-05-12T08:20:11-0400
win = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
given = [0, 0]
bad = 0
given[0], given[1] = map(int, input("Enter two integer (separated by a space): ").split())
for i in range(8):
    if (given[0] in win[i]):
        if (given[1] in win[i]):
            win[i].remove(given[0])
            win[i].remove(given[1])
            print(win[i])
            

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS