Skip to content

Instantly share code, notes, and snippets.

@phrz
Last active September 27, 2017 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phrz/cd20575ddf39da6630aa6d06750d7579 to your computer and use it in GitHub Desktop.
Save phrz/cd20575ddf39da6630aa6d06750d7579 to your computer and use it in GitHub Desktop.
A Tic Tac Toe game (265B)
Y,G,B=lambda i:B[A[i]],0,['-']*9
while 1:
G=1-G;t='XO'[G]
for x in 0,3,6:print(B[x:x+3])
while 1:
q=ord(input(t)[0])-49
if B[q]=='-':B[q]=t;break
A=[*range(9),0,4,8,2,4,6,0,3,6,1,4,7,2,5,8]
exec("if(Y(0)==Y(1)==Y(2)!='-'):print('W'+t);exit()\nA=A[3:]\n"*8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment