[Question]
  [
Your task is to output all possible ways to end a game with a tie (all rows, columns, and diagonals are completely filled and do not have 3 X's or 3 O's, and there are exactly 5 X's and 4 O's in total) in [Tic-Tac-Toe](https://en.wikipedia.org/wiki/Tic-tac-toe) (assuming X goes first):
```
OXO  XXO  XOX  OXX
XOX  OOX  XOX  XOO
XOX  XXO  OXO  OXX
XOX  XOX  OXX  XXO
OOX  XOO  XOO  OOX
XXO  OXX  XOX  XOX
XOX  OXX  OXO  XOO
XXO  XXO  OXX  OXX
OXO  OOX  XOX  XXO
OXO  XXO  XOX  OOX
XXO  OXX  OXX  XXO
XOX  XOO  OXO  OXX
```
(It does not need to be arranged in the above way.)
## Rules
* Output can be in any convenient format.
* You may use different characters to represent X and O as long as they are distinct.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/q/1061) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins.
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~16~~ 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“œNZjr⁽⁾ƈ‘+⁹BUƬ
```
A niladic Link that yields a list of lists of lists (a 2 by 8 array of flattened boards) with `1`s representing `X`s and `0`s representing `O`s.
**[Try it online!](https://tio.run/##ASUA2v9qZWxsef//4oCcxZNOWmpy4oG94oG@xojigJgr4oG5QlXGrP// "Jelly – Try It Online")** Or see them in the format and order given in the question [here](https://tio.run/##y0rNyan8//9Rw5yjk/2isooeNe591LjvWMejhhnajxp3OoUeW/P/0KKHu/qiDY10zHVMdAxNdYx0DIG0gY6ZjqmOpY6hsY6hjqGhjoUOkGEW@3B3d/GjpjXGxSZRQArIAxoX4Z8FZINQ4z4FhUggIwvIOrTt0Lb/AA "Jelly – Try It Online").
### How?
Using only reflection in one axis is terser than using four rotational symmetries like in my original 16-byte code (below).
```
“œNZjr⁽⁾ƈ‘+⁹BUƬ - Link: no arguments
“œNZjr⁽⁾ƈ‘      - Code page indices = [30,78,90,106,114,141,142,156]
          +⁹    - add 256 -> [286, 334, 346, 362, 370, 397, 398, 412]
            B   - to binary
              Ƭ - collect up while distinct applying:
             U  -   reverse each
```
---
##### Previous @16 bytes:
```
“⁾⁽ʠ⁷‘ḤBs€3ZṚ$Ƭ€
```
A niladic Link that yields a list of lists of lists of lists (a 4 by 4 array of 2d boards) with `1`s representing `O`s and `0`s representing `X`s.
**[Try it online!](https://tio.run/##AS0A0v9qZWxsef//4oCc4oG@4oG9yqDigbfigJjhuKRCc@KCrDNa4bmaJMas4oKs//8 "Jelly – Try It Online")** Or see them in the format and order given in the question [here](https://tio.run/##y0rNyan8//9Rw5xHjfseNe49teBR4/ZHDTMe7ljiVPyoaY1x1MOds1SOrQEy/x9a9HB3N1CZf0QUkAsUB5MzgaRStKGOsY6BjmFsFpAHQo37FBQigYwsIOvQtkPb/gMA "Jelly – Try It Online").
### How?
```
“⁾⁽ʠ⁷‘ḤBs€3ZṚ$Ƭ€ - Link: no arguments
“⁾⁽ʠ⁷‘           - Code page indices = [142,141,165,135]
      Ḥ          - double -> [284,282,330,270]
       B         - to binary -> [[1,0,0,0,1,1,1,0,0],
                                 [1,0,0,0,1,1,0,1,0],
                                 [1,0,1,0,0,1,0,1,0],
                                 [1,0,0,0,0,1,1,1,0]]
        s€3      - split each into threes -> [[[1,0,0],
                                               [0,1,1],
                                               [1,0,0]],
                                              [[1,0,0],
                                               [0,1,1],
                                               [0,1,0]],
                                              [[1,0,1],
                                               [0,0,1],
                                               [0,1,0]],
                                              [[1,0,0],
                                               [0,0,1],
                                               [1,1,0]]]
               € - for each:
              Ƭ  -   collect up while distinct applying:
             $   -     last two links as a monad:
           Z     -       transpose  }
            Ṛ    -       reverse    } - together these rotate a quarter
```
[Answer]
# [Desmos](https://desmos.com/calculator), ~~142~~ ~~138~~ ~~123~~ ~~120~~ ~~112~~ 111 bytes
-8 bytes thanks to [@fireflame](https://codegolf.stackexchange.com/users/68261/fireflame241)
-1 byte thanks to [@Steffan](https://codegolf.stackexchange.com/users/92689/steffan)
```
X=x-[0...3]4+.5
\mod([23312905373,30555191537,48690981746,53478745886]/2^{3\floor(y)+\floor(X)},2)>.99\{0<X<3\}
```
[Try It On Desmos!](https://www.desmos.com/calculator/f841kp0vis)
[![Rendered in desmos](https://i.stack.imgur.com/Gh7um.png)](https://i.stack.imgur.com/Gh7um.png)
[Answer]
# [///](https://esolangs.org/wiki////), 97 bytes
```
/g/ \/\///a/OXOgb/XXOgc/XOXgd/OXXge/XOOgf/OOX /abcdccdbcdaeabcf
cfcefeefbbddbddb
cbadbdccafcbcead
```
[Try it online!](https://tio.run/##ZY47DgMxCER7n8I34Ci0FNvws1Ok8/3l4M/GWUUy@Gk0DLQ3t5e33qFCvuACAAYkrAIUXYGQqoVC1YOxFkCkDCxqqhadPbgkLerFvYiYjZdUOECVi4o6W@8Rm2lUBETg/L/8o08fYn74o9INaxA34@E9sELoj2fAEvFhOJfgWbA335cM3wc "/// – Try It Online")
I tried rearranging them so that more duplicates would appear together but it didn't save any bytes. I'm sure theres more that can be done here though. Good luck to whoever takes this on in Regenerate, I did not have the guts.
Note: /// programs do not take any input, so don't worry about the input being used in the TIO link, lol.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 17 bytes
```
»~qǔ:ṙ⁋»₆τ¦₈+b:RJ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLCu35xx5Q64bmZ4oGLwrvigobPhMKm4oKIK2I6UkoiLCJ24bmFdsKyduKBi2BcXG5cXG5gamAxMGBgWE9gxL8iLCIiXQ==) Port of 05AB1E thanks to Steffan.
```
          ¦       # Cumulative sums of...
        ₆τ        # Base 64 digits of...
»~qǔ:ṙ⁋»          # Compressed integer
           ₈+     # + 256
             b    # Convert each to binary
              :RJ # Append each matrix reversed
```
[Answer]
# [R](https://www.r-project.org/), ~~113~~ ~~111~~ 110 bytes
*Edit: -1 byte, and from that idea -1 more, and then another -1 more, all thanks to pajonk*
```
for(i in 0:511)sum(a<-matrix(i%/%2^(0:8)%%2,3))==5&all(rowSums(rbind(a,t(a),diag(a),a[1:3*2+1]))%%3)&&print(a)
```
[Try it online!](https://tio.run/##FctBCsIwEEDRq3STMKMRm4RCCfYULkVhpCgDTVKmDXr7aFZ/877U@soC3HHq@jBYi1uJQJdTpF34C6zOyj2gDyMq5YxHnKZB07KA5M@1xA3kyWkGMjsQmpnp3Uo3G/zBHe0d/59HrVfh1EitPw "R – Try It Online")
Outputs tic-tac-toe matrices using `1`s for Xs and `0`s for Os.
Calculates 3x3 matrices of binary digits of 0...511, and checks whether any of the column sums, row sums, diagonal or antidiagonal are equal to zero modulo 3 (meaning that they're all Xs (3 = 0 mod 3) or all 0s (0)).
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~90 ...~~ 45 bytes
```
"s*.
-0
	".bytes{|k|puts"%09b"%$.+=k}
```
[Try it online!](https://tio.run/##KypNqvz/X6lYS4BDj4lH14CHk51DmpFPSS@psiS1uLomu6agtKRYSdXAMklJVUVP2za79v9/AA "Ruby – Try It Online")
## How it works:
* If we can flatten the array, this means we only have to output 16 numbers between 115 and 412.
* Instead of using the numbers directly, I sort them and use the successive difference. This limits the range to 1-115, which is within the boundaries of ASCII
[Answer]
# [Python 3](https://docs.python.org/3/), 64 bytes
* -2 bytes suggested by pxeger.
```
for i in'ƍŎţåĞŲñƎŪã­ƜŚsµ':print(f"{ord(i):09b}")
```
[Try it online!](https://tio.run/##AUsAtP9weXRob24z//9mb3IgaSBpbifGjcWOxaPDpcKdxJ7FssOxxo7FqsOjwq3GnMWac8K1JzpwcmludChmIntvcmQoaSk6MDlifSIp//8 "Python 3 – Try It Online")
A really boring answer. Or [65 bytes](https://tio.run/##AUwAs/9weXRob24z//9mb3IgaSBpbifWjdWO1aPTpdKd1J7VstOx1o7VqtOj0q3WnNWa0bPStSc6cHJpbnQoYmluKG9yZChpKSlbNDpdKf//) without unprintable.
---
And this is a (somehow) interesting [94 bytes](https://tio.run/##Fci7DYAgFADAVYiVWAnKR5egJUEKfEikQYIUOj3GKy@/9bzS1FouMdV@MJ3SSmmt9JY681fEqzXrZMNVUEQxobuWfnwo5QJmTzgsnggpAmEjk57x3ZEZhHNwHNRxKiFgi1v7AA) answer:
```
print(*["OXOOXXOX\n"[int(i):][:3]for i in str(0x2267c4d16c9d1787f15058d56ba14c7aacee2a628cf)])
```
-2 bytes suggested by G B. Maybe it can be golfed more.
[Answer]
# [brainf\*\*\*](https://github.com/TryItOnline/brainfuck), 264 bytes
```
-.-.+.-.+.-..+.-.>.<..+...-...+.>.<.-...+...-..>.<.+.-.+..-...+.>.<.-...+..-.+.-.>.<.+.-..+...-..>.<..+...-..+.-.>.<.+.-...+..-.+.>.<.-....+...-.>.<.+.-.+.-..+.-.+.>.<.-.+..-...+.-.>.<.+...-....+.>.<.-.+.-..+.-.+.-.>.<..+..-...+..>.<..-...+..-..>.<.+.-..+.-.+.-.+.
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fV09XTxuKwYSdng2IoQfiA2kQF8ICi4C4EOWY8rpw/VDD4DpgbBR5mBaYCVBFCBugGmAq4FbC1OjBtMHk4RoQvoDaA@bC7UR2I8z3//8DAA "brainfuck – Try It Online")
Outputs the games separated by nulls. `ÿ` is `O` and `þ` is `X`.  
It's hard-coded, manipulating address 1 to switch between `255` (`ÿ`) and `254` (`þ`) as needed. After each game, `>.<` moves the pointer to address 2, prints `0` (null), and returns to address 1. A few bytes were saved by modifying the order of the games.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~25~~ ~~19~~ ~~18~~ 15 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
•“ª?’ì¦¾Ô*•bº9ô
```
-9 bytes thanks to *@CommandMaster*
Outputs the results as a list of flattened strings, each consisting of nine `1`/`0` for `X`/`O` respectively.
[Try it online.](https://tio.run/##ATwAw/9vc2FiaWX//@KAouKAnMKqP@KAmcOswqbCvsOUKuKAomLCujnDtP924oCeT1h5U8OoM8O0SsK7LMK2P/8) (Feel free to remove the footer that pretty-prints the results to see the actual result.)
**Explanation:**
```
•“ª?’ì¦¾Ô*• # Push compressed integer 2639961594228296764259
  b         # Convert it to binary: 100011110001110011010011101010101101010110101011100011011100101101100011
   º        # Mirror it: 100011110001110011010011101010101101010110101011100011011100101101100011110001101101001110110001110101011010101101010101110010110011100011110001
    9ô      # Split it into parts of size 9: ["100011110","001110011","010011101","010101101","010110101","011100011","011100101","101100011","110001101","101001110","110001110","101011010","101101010","101110010","110011100","011110001"]
            # (after which the list is output implicitly as result)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `•“ª?’ì¦¾Ô*•` is `2639961594228296764259`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 31 bytes
```
Ｆ⪪”{∨I⦄↶r↘G”⁹«⎚⪪ι³Ｆ⁴«Ｄ⟲»»‖Ｆ³«Ｄ⟲
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBI7ggJ7NEQ8k/AgQhyB9IQrggpr@SjoKlpqZCNRenc05qYpGGpjUXZ0BRZl4JVG@mjoKxJkgQbJ4JWCWnS2luAVglZ1B@SWJJKphdy1XLFZSalpOaXALig9Ubg9XDlSNU1/7//1@3LAcA "Charcoal – Try It Online") Link is to verbose version of code. Outputs all 16 3×3 boards consecutively without vertical separation. Explanation:
```
Ｆ⪪”{∨I⦄↶r↘G”⁹«
```
Split the compressed string `OXOXOXXOXXOXOOXXXOXOXXXOOXO` into three substrings of 9 letters and loop over each substring.
```
⎚
```
Clear the canvas.
```
⪪ι³
```
Split the substring into three substrings of three letters and print each on its own line.
```
Ｆ⁴«
```
Repeat four times:
```
Ｄ
```
Output the current canvas state.
```
⟲
```
Rotate the canvas.
```
»»‖
```
Reflect the last board.
```
Ｆ³«Ｄ⟲
```
Manually output three rotations, and allow the final rotation to implicitly print.
Since the output is difficult to read, here's a 38 byte version which spaces out the boards: [Try it online!](https://tio.run/##RY2xCkIhFIZnfYqDk4JNtyUaawrCuC0NLSJekuwqYjWEz27qjcSD/D985zvqJoNy0uY8uQD07K2JlIhLfcuI8i@1RkE4bBiDD0Y7q2WgbIvRKZi5bF1n0ttR@p/NcBgYh4MzMyUARXBnrIPvGtvxddOi/fPhmxaNLsqoW0444VFPVqtYe@OHxv/xTqec8@plvw "Charcoal – Try It Online") Link is to verbose version of code.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 51 bytes
```
ṁ₃{{0|1}ᵐ².c+5∧.{|\|↺ʰ↻ᵗ{bᵐhᵐg}|↺ᵗ↻ʰ↰₄}ᶠ{⊇Ċ≠}ᵐ²∧}ᶠd
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@HOxkdNzdXVBjWGtQ@3Tji0SS9Z2/RRx3K96pqYmkdtu05teNS2@@HW6dVJQNkMIE6vBQkDRYDiIMkNj5paah9uW1D9qKv9SNejzgUQY4BGgERT/v//HwUA "Brachylog – Try It Online")
Absurdly long but at least it's not boring hardcoding. I'm sure there are shorter ways to describe the constraints of the matrix.
### Explanation
```
ṁ₃                                 Take a 3x3 matrix
  {                          }ᶠ    Find all:
   {0|1}ᵐ².                          The matrix is filled with 0s and 1s
   .c+5∧                             The sum of all elements is 5
   .{                      }ᶠ        Find all:
     |                                 The original matrix
      \|                               The transpose
        ↺ʰ↻ᵗ{bᵐhᵐg}|                   The anti-diagonal
                    ↺ᵗ↻ʰ↰₄             The diagonal
   {⊇Ċ≠}ᵐ²∧                          Each row must have at least two different elements
d                                   Remove duplicates
```
[Answer]
# [lin](https://github.com/molarmanful/lin), 50 bytes
```
\OX9`/\ \­ƎŪãŖţåƍŲñĞµƜŚs <chars g:
```
[Try it here!](https://replit.com/@molarmanful/try-lin) Generates a list of lists where each row is a tied board.
Copy-paste-friendly version for testing (includes pretty-printing):
```
\OX9`/\ ; g: ((( 3cols ( str outln ) map ) ' n\ outln ) map ) '
[173 398 362 227 342 355 229 397 370 241 157 286 181 412 346 115]
```
## Explanation
* `\OX9`/\` get all length-9 sequences of X's and O's
* `\... <chars` convert string to charcodes
* `g:` use charcodes as indices in list of length-9 sequences
[Answer]
# [Rust](https://www.rust-lang.org), 168 bytes
```
let g=|m|[7,292,146,180,56,448,73,448,84,273].iter().all(|b|b&m!=*b);let f=||(0..512).filter(|m:&u16|m.count_ones()==4&&g(*m)&&g(!m)).fold((),|_,b|print!("{b:0>9b}
"));
```
[Attempt This Online!](https://ato.pxeger.com/run?1=JY5BbsIwEEX3nIKwiGbQ1EqCSQKRe5GqQrjEKJLtVMFZMZyETRa0Qtyot4E0q6cvPT39663rT2F4GD93-8YDnn_6YN7Kv7utw_yo2PFHQdkmo1TmlJYJrXOSsqRi9Y9SUlasPkUT6g5Q7K0F1qxjF6mlxmqMGMUMiRDrNENhGjua7LZxn-bsxFfb-7BrfX0CVErG8RGWDkdEDl9-aw8ASLwjzd9d40MEi7PeJu8bfZktEKvp768BrGaXaQzDxCc)
Prints the result in binary. 1=X and 0=O
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 97 bytes
```
9$*0512$*
1
¶$`
+`(1+)\1
$+0
01
1
.+(.{9})
$1
G`(1.*){5}
...
[$&]
A`(\d)(.)*\1(?<-2>.)*(?(2)^)\1
```
[Try it online!](https://tio.run/##K0otycxL/P@fy1JFy8DU0EhFi8uQ69A2lQQu7QQNQ23NGEMuFW0DLgNDoLCetoZetWWtJpeKIZc7UFZPS7PatJZLT0@PK1pFLZbLMUEjJkVTQ09TK8ZQw95G18gOyNSw1zDSjAOa8/8/AA "Retina 0.8.2 – Try It Online") Outputs each board with the rows marked in the format `[101][101][010]` using `1` for `X` and `0` for `O`. Explanation:
```
9$*0512$*
1
¶$`
```
Count up to 511 in unary, with padding. (`0` gets listed twice, but we'll delete that later anyway.)
```
+`(1+)\1
$+0
01
1
```
Convert to binary.
```
.+(.{9})
$1
```
Trim the result back down to 9 digits.
```
G`(1.*){5}
```
Keep those with (at least) 5 `X`s. (Boards with 6 or more `X`s will always have at least one winning line so will get eliminated anyway.)
```
...
[$&]
```
Split into three groups of three.
```
A`(\d)(.)*\1(?<-2>.)*(?(2)^)\1
```
Omit boards which aren't ties (i.e. wins or invalid). See my answer to [Tic-Tac-Toe - X or O?](https://codegolf.stackexchange.com/q/144116) for how the regular expression works.
[Answer]
# [Perl 5](https://www.perl.org/) `-Mbigint`, 65 bytes
```
say for 0xce63b1b72b558eb54e8f3c5cae35aab53a73->to_bin()=~/.{9}/g
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVIhLb9IwaAiOdXMOMkwydwoydTUIjXJ1CTVIs042TQ5MdXYNDExydQ40dxY164kPz4pM09D07ZOX6/aslY//f//f/kFJZn5ecX/dX1N9QwMDYB0UmZ6Zl4JAA "Perl 5 – Try It Online")
Uses `1` for `X` and `0` for `O`; Outputs flat strings, one grid per line.
]