21 votes

Is this Tic-Tac-Toe board valid?

JavaScript (ES6), 88 87 bytes s=>(a=[...s]).sort()[5]-a[3]&[7,56,73,84,146,273,292,448].every(j=>j&i,i=`0b`+s^~-a[4]) Takes input as a string of 9 <...
Neil's user avatar
  • 170k
14 votes

Is this Tic-Tac-Toe board valid?

Python 3, 131 127 125 100 96 bytes For a different algorithmic approach (and one that will be really suited to these multi-byte golfing languages with built-in compression), instead of calculating if ...
Ken Y-N's user avatar
  • 386
12 votes

Is this Tic-Tac-Toe board valid?

Batch, 140 bytes @set/aXXX=OOO=O=0 @for %%l in (%* %1%2%3 %1%4%7 %1%5%9 %2%5%8 %3%5%7 %3%6%9 %4%5%6 %7%8%9)do @set/a%%l+=1 @cmd/cset/a!XXX*!(O-=5)+!OOO*!~O Takes ...
Neil's user avatar
  • 170k
12 votes

All Possible Ties in Tic-Tac-Toe

Jelly,  16  15 bytes “œNZjr⁽⁾ƈ‘+⁹BUƬ A niladic Link that yields a list of lists of lists (a 2 by 8 array of flattened boards) with ...
Jonathan Allan's user avatar
10 votes

Is this Tic-Tac-Toe board valid?

Mathematica, 82 75 bytes Thanks to Martin Ender for saving 7 bytes! ...
Greg Martin's user avatar
  • 15.7k
8 votes
Accepted

What's your next move?

Perl, 101 98 bytes Includes +4 for -0p Run with the input on STDIN ...
Ton Hospel's user avatar
  • 14.9k
8 votes

Tic-Tac-Toe - X or O?

Jelly,  16 15  14 bytes U,Z;ŒD$€ẎḄỊÐḟḢ A monadic link accepting a list of lists (the rows - or columns) with the values: ...
Jonathan Allan's user avatar
8 votes

Determine Tic-Tac-Toe winner (round based)

Retina, 114 bytes (.)(.) $1O$2X ^ 123;;456;;789¶X {`(.)(.*¶)(.)\1 $3$2 }`.*(.)(.)*\1(?<-2>.)*(?(2)(?!))\1.*¶(..)* $1$#3 .*¶ T T`d`Rd Try it online! Based ...
Neil's user avatar
  • 170k
8 votes
Accepted

Scoring Quantum Tic-Tac-Toe

Python 3.8 (pre-release), 419 371 351 bytes -48 bytes following suggestions from @ovs -16 bytes thanks to @JBernardo ...
fireflame241's user avatar
  • 16.3k
7 votes

Print this tic-tac-toe board!

JavaScript (ES6), 136 133 129 bytes ...
Arnauld's user avatar
  • 192k
7 votes

Tic-tac-toe with only crosses as quick as possible

Java, 14m 31s This is essentially the program which I posted to OEIS after using it to extend the sequence, so it's a good reference for other people to beat. I've tweaked it to take the board size ...
Peter Taylor's user avatar
  • 43.1k
7 votes

All Possible Ties in Tic-Tac-Toe

Desmos, 142 138 123 120 112 111 bytes -8 bytes thanks to @fireflame -1 byte thanks to @Steffan ...
MathEnthusiast314's user avatar
6 votes

Is this Tic-Tac-Toe board valid?

Pyth - 36 bytes I include diagas and use two ternaries instead. JsM+sCBQm@VdU3_BQ?q5KssQ*FJ?qK4!}3JZ Test Suite
Maltysen's user avatar
  • 25.7k
6 votes

Tic Tac Toe: print all possible positions without duplicates

Jelly, 192 179 168 bytes ...
fireflame241's user avatar
  • 16.3k
6 votes

Tic-Tac-Toe - X or O?

Javascript (ES6), 103 87 bytes a=>"012+345+678+036+147+258+048+246T".replace(/\d/g,n=>a[n]||!1).match(/(\d)\1\1|T/)[0] Input X is represented as ...
Endenite's user avatar
  • 4,061
6 votes
Accepted

Play tic-tac-toe and never lose

Befunge, 181 168 bytes ...
James Holderness's user avatar
6 votes

Determine Tic-Tac-Toe winner (round based)

MATL, 39 bytes 3:g&+XIx"IX@oXK@(XIt!yXdyPXd&hK=Aa?KX@. Output is 1 and R, in ...
Luis Mendo's user avatar
  • 104k
6 votes

All Possible Ties in Tic-Tac-Toe

///, 97 bytes /g/ \/\///a/OXOgb/XXOgc/XOXgd/OXXge/XOOgf/OOX /abcdccdbcdaeabcf cfcefeefbbddbddb cbadbdccafcbcead Try it online! I tried rearranging them so that ...
thejonymyster's user avatar
5 votes

Is this Tic-Tac-Toe board valid?

JavaScript (ES6), 101 bytes Takes input as a 9-bit binary mask where X = 1 and O = 0 (MSB = top left cell, LSB = bottom right ...
Arnauld's user avatar
  • 192k
5 votes

Is this Tic-Tac-Toe board valid?

Python 2, 158 132 109 92 91 123 bytes def v(b):f=sum(b,());w={x[0]for x in b+zip(*b)+[f[::4],f[-3:1:-2]]if len(set(x))==1};return sum(map(`b`.count,w))==len(w)*5 ...
Jake Cobb's user avatar
  • 220
5 votes

Print this tic-tac-toe board!

Python (2.7), 188 180 bytes ...
Joshua David's user avatar
5 votes
Accepted

Tic-tac-toe with only crosses as quick as possible

C++11, 28s This also uses a dynamic programming approach based on rows. It took 28 seconds to run with argument 13 for me. My favorite trick is the next function ...
feersum's user avatar
  • 31.4k
5 votes

Tic-Tac-Toe and Chess, with fewest [distinct] characters

APL (Dyalog Unicode), 369 characters, score 28 ...
Bubbler's user avatar
  • 76k
5 votes

Is this Tic-Tac-Toe board valid?

R, 88 82 bytes x=scan();`if`(sum(x)%in%4:5,all(apply(combn(which(x==(sum(x)<5)),3),2,sum)!=15),F) All combinations of three integers from 1 to 9 that sum up ...
ixodesbeta's user avatar
5 votes

Play tic-tac-toe and never lose

Python 3, 18 bytes lambda a:a+a%2*2-1 Try it online! This brilliant AI will always force a tie, and sometimes win if you let it. The grid is numbered in a spiral, ...
Samuel Waller's user avatar
5 votes

Determine Tic-Tac-Toe winner (round based)

Javascript (ES6), 130 bytes ...
Endenite's user avatar
  • 4,061
5 votes

All Possible Ties in Tic-Tac-Toe

Vyxal, 17 bytes »~qǔ:ṙ⁋»₆τ¦₈+b:RJ Try it Online! Port of 05AB1E thanks to Steffan. ...
emanresu A's user avatar
  • 37.8k
5 votes

All Possible Ties in Tic-Tac-Toe

Ruby, 90 ... 45 bytes "s*. -0 ".bytes{|k|puts"%09b"%$.+=k} Try it online! How it works: If we can flatten the ...
G B's user avatar
  • 21.9k
5 votes

All Possible Ties in Tic-Tac-Toe

R, 113 111 110 bytes Edit: -1 byte, and from that idea -1 more, and then another -1 more, all thanks to pajonk ...
Dominic van Essen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible