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
0 1 2
3 4 5
6 7 8
the first line of input contains space-seperated integers representing the cells where Ravan his first two pieces
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
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])
Comments
Leave a comment