g | x | w | all
Bytes Lang Time Link
019Dyalog APL250731T165416ZAaron
088AWK250730T181119Zxrs
097Swift 6250502T172909ZmacOSist
069Tcl180414T200655Zsergiol
008Vyxal 3 s240131T181315Zpacman25
775Vyxal Hj240204T203308Zpacman25
012Uiua240131T201553ZJoao-3
042Ruby221013T020834ZJordan
017Jelly161227T113026ZErik the
01505AB1E161227T142932ZErik the
00905AB1E201009T090155ZKevin Cr
032Perl 5180512T070324ZDom Hast
015Japt180424T195207ZOliver
048Perl 5180425T024101ZXcali
072JavaScript Node.js180425T012125Zl4m2
114Python 2180424T230158ZHusnain
056Python 2171009T050609ZKoishore
074Python 3171008T193802ZCursorCo
027J171008T184344ZFrownyFr
011Pyth150803T144835ZBeta Dec
103Python 3161111T123513ZNeRoboto
055Perl161111T203102ZDenis Ib
052Perl161112T093418ZDenis Ib
098Prolog SWI161111T140958ZEmigna
055PHP161111T132923ZTitus
049Python 2160805T080829Zxnor
080Python 3160805T071329ZDestruct
077JavaScript150608T184957Zedc65
068Ruby150804T200422Zdaniero
065POWERSHELL150731T111538Zblabb
092Swift 2150731T105154ZGoatInTh
097C150731T115646ZCole Cam
111C#150731T090152ZStephan
054Haskell150611T212653Znimi
086Ruby150718T212744ZPiccolo
092Ruby150718T202412Zclapp
033Matlab150610T103848ZOebele
081Python 2150610T071012Zdieter
012CJam150609T212738ZMartin E
025Mathematica150609T215426ZMartin E
095Python 2150609T214022ZKade
011K150609T212401ZJohnE

Dyalog APL, 19 chars

↑{3 3⍴(9⍴2)⊤⍵}¨⍳512

Same as the J's and K's, just figured I'd throw this in for completeness.

               ⍳512  Numbers 1 through 512 (2^9)
 {           }¨      For each of those
      (9⍴2)            Get 9 2's
           ⊤⍵          To encode the input as binary
  3 3⍴                 Reshape that as a 3x3 square
↑                    And mix so it looks pretty

AWK, 88 bytes

END{for(;i<512;i++){for(j=0;j<9;){printf and(i,2^(8-j))?1:0;printf(j+++1)%3?X:RS}print}}

Attempt This Online!

Swift 6, 97 bytes

(512..<1024).map{[_](String($0,radix:2))}.map{print($0[1..<4]+"\n"+$0[4..<7]+"\n"+$0[7...]+"\n")}

Try it on SwiftFiddle! (SwiftFiddle doesn't seem to display completely empty lines in the output — replace the last "\n" with "\n " to fix this. Running the program locally doesn't have this problem.)

Tcl, 69 bytes

time {puts [regsub -all ... [format %09b [expr [incr i]-1]] &\n]} 512

Try it online!

Vyxal 3 s, 12 8 bytes

₀2(3ẋ“¶+

Try it Online! port of the 05ab1e answer

Vyxal Hj, 62 bitsv2, 7.75 bytes

U2(3ÞẊṅ¶+
U2(3ÞẊṅ¶+­⁡​‎‏​⁢⁠⁡‌⁢​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢⁢​‎‏​⁢⁠⁡‌⁢⁣​‎‏​⁢⁠⁡‌­
# ‎⁡#H flag sets stack to 100
U          # ‎⁢uniquify the digits, getting a list of [1,0]. This didn't work with the builtin for 10 when I tried it
 2(        # ‎⁣iterate twice
   3ÞẊ     # ‎⁤cartesian power of 3
      ṅ¶+  # ‎⁢⁡joined on nothing with a newline appended
# ‎⁢⁢j flag joins top of stack on newlines
# ‎⁢⁣this leads to the double newline separator
💎

Created with the help of Luminespire.

Try it Online!

Bitstring:

01100100111011000111001100111101010001110000111111010101000100

Port of Kevin's 05ab1e answer, with different separators.

Uiua, 12 bytes

≡(↯3_3)⋯⇡512

Outputs an array of 512 3x3 bit matrices. Makes clever use of the bits ⋯ primitive, which converts all numbers in an array to lists of bits.

With &gifs, you can make a very tiny GIF cycling every grid.

Pad, GIF version

Ruby, 42 bytes

512.times{puts ("%09b"%_1).scan(/.../),$/}

Attempt This Online!

Jelly, 17 bytes

512+ḶBḊ€s€3Y€j“¶¶

Try it online!

Uses 01. Because of a bug in , I had to use “¶¶ instead of ⁾¶¶, because otherwise, instead of two newlines, two pilcrows would have showed up in the output. As you can see, though, that didn't cost me any bytes at all.

K beats this, so this must be further golfed down.

05AB1E, 15 bytes

žAFNžA+b¦3ô»,¶?

Try it online!

05AB1E, 9 bytes

T3ã¶«3ãJ»

Uses the digits [1,0]. The T could be replaced with , , or to use the digits [2,6], [9,5], or [3,6] respectively.

Try it online.

Outputting as an unformatted list could have been 5 bytes: T3ã3ã.

Explanation:

T          # Push 10
 3ã        # Take the cartesian power of 3 with its digits:
           #  ["111","110","101",...,"000"]
   ¶«      # Append a newline to each triplet
           #  ["111\n","110\n","101\n",...,"000\n"]
     3ã    # Take the cartesian power of 3 with this list of strings:
           #  [["111\n","111\n","111\n"],["111\n","111\n","110\n"],...,["000\n","000\n","000\n"]]
       J   # Join each inner list together
           #  ["111\n111\n111\n","111\n111\n110\n",...,"000\n000\n000\n"]
        »  # And join that list by newlines
           #  "111\n111\n111\n\n111\n111\n110\n\n...\n000\n000\n000\n"
           # (after which it is output implicitly as result)

Perl 5, 32 bytes

$_=("{.,#}"x3 .$/)x3;say<"$_\n">

Try it online!

Japt, 16 15 bytes

#f4o8³_¤Åò3 ·+R

Try it online!

Perl 5, 48 bytes

say((sprintf"%09b",$_)=~s%...%$&$/%gr)for 0..511

Try it online!

JavaScript (Node.js), 72 bytes

h=console.log;f=u=>h(u/4&1,u/2&1,u&1)|u/8;for(i=0;i<512;h``)f(f(f(i++)))

Try it online!

JavaScript (Node.js), 64 bytes

for(i=0;i<512;f(f(f(i++))))f=u=>console.log(u/4&1,u/2&1,u&1)|u/8

Try it online!

JavaScript (Node.js), 75 bytes

for(i=511;++i<1024;f(f(f(i))))f=u=>console.log(u.toString(2).slice(-3))|u/8

Try it online!

Python 2, 114 bytes

from itertools import *
for i in product(".X",repeat=9):
    i="".join(i);print i[0:3]+"\n"+i[3:6]+"\n"+i[6:]+"\n"

Try it online!

Python 2, 56 bytes

from itertools import*
print set(combinations('X.'*9,9))

Try it online!

Returns the 512 configurations as a set object in python. Refer to ungolfed version to make output more readable.

Ungolfed Version to make output more readable:

Python 2, 121 bytes

from itertools import*
for i in set(combinations('X.'*9,9)):
	for j in range(3):print''.join(list(i))[j*3:(j*3)+3]
	print

Try it online!

Python 3, 74 bytes

i=512;b="\n"
while i:i-=1;a=format(i,'09b');print(a[:3]+b+a[3:6]+b+a[6:],b)

Just a little shorter than Destructible Lemon's answer

J, 27 bytes

echo@<"2'.X'{~_3]\"1#:i.512

Try it online!

Pyth, 11 bytes

V^`T9jbc3Nk

Try it here!

Thanks @Jakube :)

Python 3, 123 121 109 103 bytes

Here is my old one:

import itertools
[print(a+b+c,d+e+f,g+h+i,'\n',sep='\n') for a,b,c,d,e,f,g,h,i in itertools.product(['X','.'],repeat=9)]

And here is my new one:

import itertools as i
[print(a[:3],a[3:6],a[6:],'\n',sep='\n') for a in i.product(['X','.'],repeat=9)]

This prints extra characters but the OP said ASCII art is allowed which implies multiple characters are fine.

Perl, 56 55 bytes

print$_/9&1<<$_%9?1:0,$/x(!(++$_%3)+!($_%9))for+0..4607

Output:

000
000
000

100
000
000
...

Perl, 52 bytes

printf+("%03b
"x3).$/,$_&7,$_/8&7,$_>>6&7 for 0..511

or 54 bytes:

print map$_.$/,sprintf('%09b',$_)=~/.../g,''for 0..511

or Perl 5.14+, 48 bytes:

say sprintf('%09b',$_)=~s/.../$&\n/gr for 0..511

Prolog (SWI), 98 bytes

Output is a list of 3x3 matrices containing the elements 0 and 1.

r([]).
r([H|T]):-between(0,1,H),r(T).
p(Y):-Z=[[_,_,_],[_,_,_],[_,_,_]],findall(Z,maplist(r,Z),Y).

Online interpreter

I feel like the matrix generation could be shorter.
It should be possible to fit the between in a forall or something similar, but I can't figure out how.

Golfing tips appreciated.

PHP, 55 bytes

for(;$c<512;)echo chunk_split(sprintf("%09b ",$c++),3);

uses 0 and 1. Run with -r.

Python 2, 49 bytes

i=2048;exec"print bin(i/4)[i%4*3+3:][:3];i+=1;"*i

Split the binary expansion of i. The length-10 binary values 512 through 1023 are used, cutting off the initial 1 (and prefix 0b). These are split into chunks of 3 as windows [3:6], [6:9], [9:12], and [12:15], with the last one blank to make a blank line. Iterating over the four slices is collapsed with the outer loop of counting through 512 numbers with the divmod trick.

Python 3, 80 bytes

for i in range(512):print("\n".join(format(i,'09b')[j:j+3]for j in(0,3,6)),"\n")

I managed to outgolf someone :)

JavaScript, 77 80

Revised after the revision of the OP. Now we have a question, so here is an answer.

Run the snippet in any browser to test.

// Test: redefine console to have output inside the snippet

console = { log: function(x) { O.textContent+=x+'\n\n';} }

// Solution: 77 chars (note, distinct outputs to console are automatically separed)
  
for(i=511;++i<1024;)console.log(i.toString(2).slice(1).match(/.../g).join`
`)
<pre id=O></pre>

Old post: graphic display in a browser, with javascript and canvas. ~300 byte of code (can be made shorter).

Run the snippet below.

d=8, // Min block size
C.width=d*64,C.height=d*128,
T=C.getContext('2d')

for(i=0;i<512;i++)
{
  bx=4*(i/32|0)
  by=4*(i%32)
  for(b=1,j=0;j<9;j++,b+=b)    
  {
    if(b&i) 
      x=j/3|0, y=j%3, T.fillRect((bx+x)*d,(by+y)*d,d,d);
  }
  T.strokeRect(bx*d,by*d,d*3,d*3);
}
<canvas id=C></canvas>

Ruby, 68 bytes

Prints the exact same output as the example given in the question

puts (0..511).map{|i|("%09b"%i).tr("01",".X").gsub(/.../){$&+$/}}*$/

POWERSHELL - 65

0..511|%{[convert]::ToString($_,2).padleft(9,'0')-split"(.{3})"}

result

000

000

000


000

000

001


000

000

010


000

000

011

confirmation

(0..511|%{[convert]::ToString($_,2).padleft(9,'0')-split"(.{3})"} | measure -Line).lines/3

512

edit inspired by the mathematica answer's display of results-617

Add-Type -AssemblyName System.Drawing
$a=new-object System.Drawing.Bitmap 992,496
$g=[Drawing.Graphics]::FromImage($a)
$b=@{};$y=@{};$i=$c=$d=$z=$k=$l=$m=0;
0..511|%{$y[$d++]=[convert]::ToString($_,2).padleft(9,'0')}
while($m-lt480){while($l-lt496){for($z=($m+0);$z-lt($m+32);$z++){
      $y[$z].tochararray()|%{if($_-eq"0"){$b[$i++]=[Drawing.Brushes]::Black}
        else{$b[$i++]=[Drawing.Brushes]::White}
      }
      for($j=($l+0);$j-lt($l+30);$j+=10){
        ($k+0),($k+10),($k+20)|%{$g.FillRectangle($b[$c++],$_,$j,10,10)}
      }$k+=31
    }$k=0;$l+=31;$m+=32
  }
}$a.save("$HOME/3X3_Grid.png")

enter image description here

Swift 2, 92 bytes

Int to binary string in Swift takes up too many chars so I just use two nested loops...

var s="";for x in 0..<512{(0..<9).map{s+=($0%3==0 ?"\n":"")+"\(x>>$0&1)"};s+="\n-"};print(s)

C - 97 bytes

i;main(j){for(;i++<512;)for(j=0;j++<13;)putchar(j%4&&j<13?i%(1<<j-j/4)>(1<<j-j/4-1)-1?88:46:10);}

Basically prints the example output from the original question.

C# - 111

for(int i=0;i<512;i++)Console.WriteLine(Regex.Replace(Convert.ToString(i,2).PadLeft(9,'0'),"(.{3})","$1\r\n"));

Converts every int to its binary representation and splits every 3 chars.

Haskell, 57 54 bytes

r x=sequence[x,x,x]
u=unlines
f=putStr$u$map u$r$r".X"

f gives the same output as in the challenge description, i.e. it starts with

...
...
...

...
...
..X

...
...
.X.

Edit: @Mauris found 3 bytes to save. Thanks!

Ruby, 86 bytes

0.upto(511).map{|i|i.to_s(2).rjust(9,'0')}.each{|j|p j[0..2];p j[3..5];p j[6..8];puts}

Mine prints with quotes because p is shorter than puts, but it does still fit the rules.

Ruby, 92 bytes

0.upto(511){|i|("%09d"%i.to_s(2)).scan(/.{3}/).map{|j|j.scan(/./)}.map{|j|puts j.join};puts}

Counts in 0s and 1s, and each block is separated by an empty line (\n\n)

Matlab, 33

reshape(dec2bin(0:511,9)',3,3,[])

Was kind of fiddly to get the dimensions correct, but I am very happy with the result!

Python 2, 81

import re
for i in range(512):print re.sub('(.{3})','\\1\n',bin(i)[2:].zfill(9))

CJam, 12 bytes

2,9m*3f/N*N*

Test it here.

Uses 0 and 1 as the distinct characters.

Explanation

2,  e# Push [0 1].
9m* e# Generate all 9-tuples of 0s and 1s.
3f/ e# Split each 9-tuple into 3 subarrays of length 3.
N*  e# Join all those grids with newlines.
N*  e# Put newlines between all the length-3 arrays.

An alternative (still 12 byte) solution is

2,3m*3m*N*N*

Mathematica, 25 bytes

Image/@{0,1}~Tuples~{3,3}

Gives an array with all the grids as images, which is also directly displayed on screen:

enter image description here

(Cropped so as not to blow up the post unnecessarily.)

Python 2, 95 Bytes

Distinct characters are 0 and 1, each block is separated by \n\n.

n='\n';print(n+n).join(y[:3]+n+y[3:6]+n+y[-3:]for y in[bin(x)[2:].zfill(9)for x in range(512)])

K, 11 bytes

(3 3#)'!9#2

Output example:

((0 0 0
  0 0 0
  0 0 0)
 (0 0 0
  0 0 0
  0 0 1)
 (0 0 0
  0 0 0
  0 1 0)
 (0 0 0
  0 0 0
  0 1 1)
…

This is K's native prettyprinted representation of a list of matrices, which I think is sufficient for the problem spec. Each matrix is delimited by an enclosing set of parentheses.

And a quick sanity check to demonstrate that 512 matrices are constructed:

  #(3 3#)'!9#2
512

Very straightforward. Most of the work is in the !. First we generate a 9-long vector of 2s using "take" (9#2). Then, we make use of the "odometer" monadic form of !- a few examples illustrate its behavior:

  !2 2
(0 0
 0 1
 1 0
 1 1)
  !2 3
(0 0
 0 1
 0 2
 1 0
 1 1
 1 2)
  !2 2 2
(0 0 0
 0 0 1
 0 1 0
 0 1 1
 1 0 0
 1 0 1
 1 1 0
 1 1 1)

Then simply do a 3x3 reshape ((3 3#)) of each (') of the 9-length 0/1 vectors.