Skip to content

Instantly share code, notes, and snippets.

@WitherOrNot
Last active February 10, 2020 12:48
Show Gist options
  • Select an option

  • Save WitherOrNot/86e885896864bf9658371b6a5f90334b to your computer and use it in GitHub Desktop.

Select an option

Save WitherOrNot/86e885896864bf9658371b6a5f90334b to your computer and use it in GitHub Desktop.
Tic-Tac-Toe Python 2 Codegolf in 247 bytes
o=w=0;s=" ";b=[s]*9
while 1:
print"\n".join(["".join(b[x:x+3])for x in 0,3,6])
if w:break
h=~-input();z=b[h]==s;b[h]=[b[h],"XO"[o]][z];o=[o,2+~o][z]
for i in range(8):
e,f,g=map(int,`0x341a4a6fa990a9ee254e`[i*3:][:3]);w|=(b[e]==b[f]==b[g]!=s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment