Nov-23-2019, 03:30 PM
I have a string "x-xoxoo--" which meeans a satge in a game Tic-Tac-Toe
For example
["----x----", "o---x----", "oo--x----"] is not valid
["----xo---", "o---xo---", "x---xo---"] is not valid
x|-|x
o|x|o
o|-|-I know how to check if that one element in a list is valid:
from math import * def check(play): x=0 o=0 for item in paly: if item=="x": x=x+1 if item=="o": o=o+1 return (fabs(x-o)<=1)I want to check if for example a list
["x-xoxoo--", "x-xoxoox-", "x-xoxooxo"]describes the possible sequence of consecutive moves in the game?
For example
["----x----", "o---x----", "oo--x----"] is not valid
["----xo---", "o---xo---", "x---xo---"] is not valid