[Question]
  [
# Introduction
[Nine-Ball](https://en.wikipedia.org/wiki/Nine-ball) is a popular pool game played casually and as a competitive sport.
There is one of each numbered ball, with the numbers 1 to 9.
The game starts with all 9 of the balls in a diamond shaped rack, like so:
```
  1
 2 3
4 9 6
 5 7
  8
```
The 1 ball is always at the front of the diamond, and the 9 ball is always in the middle, with all the other balls placed randomly (the "X"s in this diagram):
```
  1
 X X
X 9 X
 X X
  X
```
# Challenge
Your challenge, given no input, is to generate and output random 9-ball pool racks in the text format of the examples. Extra surrounding whitespace is allowed.
Output may be through any convenient method, standard loopholes apply. A new rack MUST be generated on each run, you cannot just produce a single randomly-chosen rack every time. Extra surrounding whitespace is allowed.
# Example Outputs
```
  1
 2 3
4 9 5
 6 7
  8
```
```
  1
 8 3
2 9 7
 4 6
  5
```
```
  1
 2 8
3 9 7
 5 4
  6
```
Least bytes per language wins.
  
[Answer]
# [R](https://www.r-project.org/), 61 bytes
```
cat(paste0(c("  1
 ","","
","9 ","
 ","","
  "),sample(2:8)))
```
[Try it online!](https://tio.run/##K/r/PzmxRKMgsbgk1UAjWUNJQcGQS0FJRwmIuIDYEsSGCygoKGnqFCfmFuSkahhZWWhqav7/DwA "R – Try It Online")
Prints alternately the proper whitespace/newline (with 1 and 9 included) and elements of a random permutation of \$\{2,\ldots,8\}\$.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~91~~ 87 bytes
```
from random import*
print("  1\n %d %d\n%d 9 %d\n %d %d\n%3d"%(*sample(range(2,9),7),))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P60oP1ehKDEvBUhl5hbkF5VocRUUZeaVaCgpKBjG5CmopgBRTB6QsgQz4ALGKUqqGlrFibkFOakaQBPSUzWMdCw1dcw1dTQ1//8HAA "Python 3 – Try It Online")
-4 bytes thanks to xnor (final `\n %d` -> `\n%3d` and `tuple(...)` -> `(*...,)`)
[Answer]
# [Bash](https://www.gnu.org/software/bash/) or any Bourne Shell, with modern coreutils, 54 52 bytes
```
printf '  1
 %s %s
%s 9 %s
 %s %s
  %s' `shuf -i2-8`
```
[Try it online!](https://tio.run/##S0oszvj/v6AoM68kTUFdQcGQS0G1GIi4gKQliIZyFYCEukJCcUZpmoJuppGuRcL//wA "Bash – Try It Online")
-2 bytes thanks to @dzaima (use shuf -i option for an implicit seq)
Originally: 
```
printf '  1
 %s %s
%s 9 %s
 %s %s
  %s' `seq 2 8|shuf`
```
[Try it online!](https://tio.run/##S0oszvj/v6AoM68kTUFdQcGQS0G1GIi4gKQliIZyFYCEukJCcWqhgpGCRU1xRmlawv//AA "Bash – Try It Online")
I saved one byte by not including a newline at the end of the source, and another by not including one at the end of the output.
Explanation:
`seq 2 8` outputs `2 3 4 5 6 7 8` on separate lines.
`|shuf` randomly reorders them. (This is what needs modern coreutils.)
`printf <formatstring> <args>` does a C-like printf of the arguments with the format string.
[Answer]
# JavaScript (ES6), 89 bytes
```
_=>`  1
 X X
X 9 X
 X X
  X`.replace(/X/g,g=_=>m^(m|=1<<(i=Math.random()*9|0))?i:g(),m=3)
```
[Try it online!](https://tio.run/##HYy9DoIwFEZ3nuJu3CvIT3RBqD6BewejNFAqhrakEBfx2Wvj8p0znHwv8RZL58Z53RvbSz8w/2DnFqCMgAOPOFRh/wrA28zJeRKdxJznKlUstPqOemNl0@DIrmJ9Zk6Y3mqkXbUVRJfxpJBSzQ7kB@vQAIOiBgMNHAOShOATrjtrFjvJbLIKByRIIL6ZmOro638 "JavaScript (Node.js) – Try It Online")
### How?
We replace each "X" in the template with a random integer \$0\le i<9\$ such that the \$i\$-th bit in the bitmask \$m\$ is not already set, and we simultaneously update \$m\$.
We start with \$m=3\_{10}=000000011\_2\$ so that \$0\$ and \$1\$ are never chosen.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~27~~ 25 bytes
```
Ｆ⁷⊞υ‽⁻Ｅ⁷⁺²κυ↖⪪⁺⪫⪪⪫υω⁴9¦1³
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBw1xTIaC0OEOjVEchKDEvJT9Xwzczr7RYwzexQMNcRyEgB8g20lHI1tTUUSjV1LTmCijKzCvRsAot8ElNK9FRCC7IySzRACvzys/M04DwwUygkeVAXSZArGSpBCINQaQx0JT////rluUAAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆ⁷
```
Loop 7 times.
```
⊞υ‽⁻Ｅ⁷⁺²κυ
```
Create a list of the integers from 2 to 8, perform set difference with the list of integers collected so far, select a random integer, and push it to the empty list. This shuffles the integers from 2 to 8.
```
⁺⪫⪪⪫υω⁴9¦1
```
Concatenate the integers, insert a `9` after the fourth, and append a `1`. Edit: Saved 2 bytes by using @JonathanAllan's trick to insert the `9`.
```
↖⪪...³
```
Split the string into a 3×3 grid and print it diagonally thus achieving the desired output.
[Answer]
# [Python 3](https://docs.python.org/3/), 128 bytes
```
from random import*
l=[1]+sample(range(2,9),7)
l.insert(4,9)
for i in[1,2,3,2,1]:print(f"{' '.join(map(str,l[:i])):^5}");l=l[i:]
```
[Try it online!](https://tio.run/##DYnNCgIhGADvPoXsZbVkwd0iMvZJxEBI6wv/@PQS0bObh2FgpnzaK6etd485UrTpMQSxZGwHEnYtzbHaWIJj4z0dW8WViwsnYYFUHTZ2GoH4jBQoJC3FKraBNKogpMb89J3pvLwzJBZtYbWhCFqB4Vzdz7@J38IeNCjT@x8 "Python 3 – Try It Online")
Unfortunately not even close to the [straightforward solution](https://codegolf.stackexchange.com/a/197692/90219), but I spent so much time on this that I still wanted to share it.
# Ungolfed:
```
from random import *
# Generate random sampling and ensure 1st element is 1
l = [1] + sample(range(2, 9), 7)
# Ensure 5th element is 9
l.insert(4, 9)
for i in [1, 2, 3, 2, 1]: # Numbers of digits per row
    # Take i numbers from the beginning of l, join them with spaces
    # Then center the resulting string in a field of length 5 and print
    print(f"{' '.join(map(str,l[:i])):^5}")
    # Drop the just printed numbers
    l = l[i:]
```
It can be shortened but then it no longer makes use of the nifty `:^5` format specifier:
# [Python 3](https://docs.python.org/3/), 112 bytes
```
from random import*
l=[1]+sample(range(2,9),7)
l.insert(4,9)
for i in[1,2,3,2,1]:print(' '*(3-i),*l[:i]);l=l[i:]
```
[Try it online!](https://tio.run/##DYnLCsMgEADvfoW3qN0WjIVSS75EPARq2oX1wcZLv956GAZm2q9/a3FjHFyz5L28pzC3yt0I2oKNl3PPjZKa75PUCk8NDy3ohuVM3NV9BnFUliixBAsruImNvjGWrha5GOWuqMFQ8Bj1izYK6OMYfw "Python 3 – Try It Online")
A funny one without `insert` which bounces the 9 into the middle by slicing with a step size of 2:
# [Python 3](https://docs.python.org/3/), 115 bytes
```
from random import*
l=[1]+sample(range(2,9),7)+[9]
for i in[2,4,6,4,2]:print(' '*(3-i//2),*l[:i:2]);l=l[i:]+l[1::2]
```
[Try it online!](https://tio.run/##DYnLCoMwEADvfkVu5lXEWCpu8UuWHIRqu7B5kObSr09zGAZm8q9@Ulxau0oKohzx1UUhp1L1wDvO3nyPkPmU/b1P6eym7KoMbn64UhEkKKKzd/voOA@5UKxyFKOWy42mySmrGYHAefXknZHAG8YZemjtDw "Python 3 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/en/), ~~66~~ 52 bytes
```
$><<"  1
 %d %d
%d 9 %d
 %d %d
  %d"%[*2..8].shuffle
```
[Try it online!](https://tio.run/##KypNqvz/X8XOxkZJQcGQS0E1BYi4gKQliIZyFYCEkmq0lpGenkWsXnFGaVpaTur//wA "Ruby – Try It Online")
Also quite a boring answer, similar to the Perl and Bash solutions.
Saved 14 bytes thanks to [Value Ink](https://codegolf.stackexchange.com/users/52194/value-ink)!
[Answer]
# [Kotlin](https://kotlinlang.org), ~~102 95 93~~ 92 bytes
```
{List(7){it+2}.shuffled().fold("  1\n XX\nX9 X\n XX\n  X"){s,c->s.replaceFirst("X", "$c ")}}
```
[Try it online!](https://tio.run/##Lc2xDoIwFEbhWZ7iT@NwbwQSXYwmMjq5uXRgIUC1oRbSFpemz14Z3M70nWkORtv87QzUFcRV8wxO2xduOT60D3TmqMPhlGr/XpUy40Bcq9kMJIBjayFla@UF8p@AFBx92VeNr924mK4f79ptkJCihNj3EJxSVqvFp9OWGLHYLdsykCLmIuUf "Kotlin – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 24 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
7ẊŻŒHj8‘;€⁶⁽¦ỵD¤œṖz⁶ZṚ€Y
```
A full program which prints the result.
**[Try it online!](https://tio.run/##AToAxf9qZWxsef//N@G6isW7xZJIajjigJg74oKs4oG24oG9wqbhu7VEwqTFk@G5lnrigbZa4bma4oKsWf// "Jelly – Try It Online")**
### How?
```
7ẊŻŒHj8‘;€⁶⁽¦ỵD¤œṖz⁶ZṚ€Y - Main Link: no arguments
7                        - seven
 Ẋ                       - shuffle (implicit range [1..7])
  Ż                      - prepend a zero
   ŒH                    - split in half
     j8                  - join with an eight
       ‘                 - increment (vectorises)
        ;€               - concatenate each with:
          ⁶              -   a space character
                œṖ       - partition before indices:
               ¤         -   nilad followed by link(s) as a nilad:
           ⁽¦ỵ           -     2479
              D          -     digits -> [2,4,7,9]
                  z⁶     - transpose with space filler
                    Z    - transpose
                     Ṛ€  - reverse each
                       Y - join with newline characters
                         - implicit, smashing print
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 51 bytes
```
printf '  1
 %s %s
%s 9 %s
 %s %s
  %s',pick *,2..8
```
[Try it online!](https://tio.run/##K0gtyjH7/7@gKDOvJE1BXUHBkEtBtRiIuICkJYiGchWAhLpOQWZytoKWjpGensX//wA "Perl 6 – Try It Online")
I'm not really happy with how boring this solution is.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 60 bytes
```
'  1
 {0} {1}
{2} 9 {3}
 {4} {5}
  {6}'-f(2..8|Sort{Random})
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/X11BwZBLodqgVqHasJar2qhWwVKh2rgWKGQCFDIFMhSqzWrVddM0jPT0LGqC84tKqoMS81Lyc2s1//8HAA "PowerShell – Try It Online")
-17 bytes thank you @Veskah for cleaning up whitespaces
Originally:
```
'
   1
 {0}  {1}
{2}  9  {3}
 {4}  {5}
   {6}
' -f (2..8 | Sort {Get-Random})
```
[Answer]
# Perl 5, 62 bytes
```
printf"  1
 %d %d
%d 9 %d
 %d %d
  %d",sort{int(rand 3)-1}2..8
```
[Try it online!](https://tio.run/##K0gtyjH9/7@gKDOvJE1JQcGQS0E1BYi4gKQliIZyFYCEkk5xflFJNVClRlFiXoqCsaauYa2Rnp7F//8A "Perl 5 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~28~~ 26 bytes
```
4>þ`ṚŒḄYṣ1µ7ẊŻs4j8‘;€⁶ż@o⁶
```
[Try it online!](https://tio.run/##ATgAx/9qZWxsef//ND7DvmDhuZrFkuG4hFnhuaMxwrU34bqKxbtzNGo44oCYO@KCrOKBtsW8QG/igbb//w "Jelly – Try It Online")
A full program that takes no arguments and outputs a pool rack.
## Explanation
```
4>þ`                       | Outer table using 1,2,3,4 on both sides and > as the the function [0,1,1,1],[0,0,1,1],[0,0,0,1],[0,0,0,0]
    Ṛ                      | Reverse [0,0,0,0],[0,0,0,1],[0,0,1,1],[0,1,1,1]
     ŒḄ                    | Bounce [0,0,0,0],[0,0,0,1],[0,0,1,1],[0,1,1,1],[0,0,1,1],[0,0,0,1],[0,0,0,0]
       Y                   | Join with newlines
        ṣ1                 | Split at 1s
          µ                | Start a new monadic chain
           7Ẋ              | Shuffle list of 1..7
             Ż             | Prepend with zero
              s4           | Split into pieces of length 4
                j8         | Join with 8
                  ‘        | Increment by 1
                   ;€⁶     | Append space to each
                      ż@   | Zip with list generated above
                        o⁶ | Replace 0s with spaces
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~18~~ 16 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Y8L.r1†9ª•26Ià•Λ
```
-2 bytes thanks to *@Grimmy* by using a fixed length of `2` with some directions duplicated.
[Try it online.](https://tio.run/##yy9OTMpM/f8/0sJHr8jwUcMCy0OrHjUsMjLzPLwASJ@b/f8/AA)
**Explanation:**
```
Y            # Push 2
8L           # Push a list in the range [1,8]
  .r         # Randomly shuffle it
    1†       # Filter the 1 to the front
      9ª     # Append a trailing 9 (i.e. [1,3,4,8,5,2,6,7,9])
•26Ià•       # Push compressed integer 33557713
Λ            # And use the Canvas builtin with those three values
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `•26Ià•` is `33557713`.
*Canvas explanation:*
The Canvas builtin takes three arguments:  
1. The lengths of the lines to 'draw', which in this case is the fixed length of `2`.  
2. The string to 'draw', which in this case is the list `[1,#,#,#,#,#,#,#,9]` (where the `#` are random digits in the range `[2,8]`).  
3. The directions, which in this case is `33557713`. These will be the directions `[↘,↘,↙,↙,↖,↖,↗,↘]`.
With these arguments, it will draw as follows (let's take the random list `[1,3,4,8,5,2,6,7,9]` as example here):
```
2 characters (1,3) in direction 3 (↘):
1
 3
2-1 characters (4) in direction 3 (↘):
1
 3
  4
2-1 characters (8) in direction 5 (↙):
1
 3
  4
 8
2-1 characters (5) in direction 5 (↙):
1
 3
  4
 8
5
2-1 characters (2) in direction 7 (↖):
 1
  3
   4
2 8
 5
2-1 characters (6) in direction 7 (↖):
  1
   3
6   4
 2 8
  5
2-1 characters (7) in direction 1 (↗):
  1
 7 3
6   4
 2 8
  5
2-1 characters (9) in direction 3 (↘):
  1
 7 3
6 9 4
 2 8
  5
```
NOTE: Since we use a fixed length of `2`, the directions are leading in drawing the Canvas. So the trailing `3` in the directions `33557713` is mandatory for outputting the `9` here, whereas my previous 18-byter used the leading `3` with implicit wraparound to output the `9`, since the lengths-list were leading for drawing instead.
[See this 05AB1E tip of mine for a more in-depth explanation of the Canvas builtin.](https://codegolf.stackexchange.com/a/175520/52210)
[Answer]
# [Dyalog APL Extended](https://github.com/abrudz/dyalog-apl-extended), 38 bytes
```
{5 5⍴(~2⊤29010619)⍀∊⍕¨∊,∘9¨@4⊢1,1+?⍨7}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/P@1R24RqUwXTR71bNOqMHnUtMbI0MDQwM7TUfNTb8Kij61Hv1EMrgLTOo44ZlodWOJg86lpkqGOobf@od4V5LUh/7xqFR90tCuoK6lzEcQA "APL (Dyalog Extended) – Try It Online")
[Answer]
# [Red](http://www.red-lang.org), 90 bytes
```
t: random[2 3 4 5 6 7 8]foreach c{  1
 ; ;
; 9 ;
 ; ;
  ;}[prin either c >#":"[take t][c]]
```
[Try it online!](https://tio.run/##JchNCsIwFADhfU4x1AOIWv8a8BBuQxYhedIiJuU14EI8exTdDB@jktpVkvNGQ07lsV5EErk8Wx34L7dlR8@eA0dO/lZUQhyJL9gYLNZYzt/@CPbtZp0yMtVRlMhl1Q2dq@EuVO@i9619AA "Red – Try It Online")
[Answer]
## SAS, 160 Bytes
```
data;array j[9](1:9);do i=1to 1e4;l=int(2+7*ranuni(0));m=int(2+7*ranuni(0));n=j[l];j[l]=j[m];j[m]=n;end;put+2j[1]/+1j[2]j[3]/j[4]j[9]j[5]/+1j[6]j[7]/+2j[8];run;
```
Ungolfed:
```
data _null_;
  array j[9] (1:9);       **Define and populate an array; 
  do i = 1 to 1e4;        **Iterate ten thousand times;
    l=int(2+7*ranuni(0)); **make a random int;
    m=int(2+7*ranuni(0)); **make another random int;
    n=j[l];               **save num in first slot;
    j[l]=j[m];            **swap second to first slot;
    j[m]=n;               **swap original first to second slot;
  end;
  put +2j[1]/+1j[2]j[3]/j[4]j[9]j[5]/+1j[6]j[7]/+2j[8];
                          **outputs the string, / is linebreak, +# is shift over, always adds one space;
run;
```
If I wanted to do it a bit "better" but longer, I would use rand("integer",2,8);, as that is a better random number distribution, but 1 char longer each line...
I'm pretty sure PROC IML would be much smaller, as that would be more similar to the R/Python implementation. Base SAS has tools to sort rows randomly, but not columns/variables. I figure doing 10,000 random swaps is sufficiently randomized here (probably as random as any of the other implementations, anyway); could easily do 1 billion random swaps for no more characters, but 10k seems enough.
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), 62 bytes
```
2345678(~z%|&(~z%|')&^)  ,,1.
, ,. ,.
,. ,9. ,.
, ,. ,.
,  ,,.
```
[Try it online!](https://tio.run/##y05N///fyNjE1MzcQqOuSrVGDUyqa6rFaSoo6OgY6nHpKOjoAREXiLSEsGAiIBV6//8DAA "Keg – Try It Online")
Remove the `z%`' s for -4 bytes but a *really long* execution time. 
This:
* Pushes the numbers 2-8 onto the stack.
* Shuffles everything in a very interesting way.
* Prints out the required shape.
[Answer]
# APL, 37 chars/bytes
```
2⌽t⌽↑⍕¨((t←1 2 3 2 1)/⍳5)⊆1,5⌽9,1+?⍨7
```
permutation of numbers from 2 to 8
```
1+?⍨7
```
add leading 9, shift 5 positions to the left, add leading 1
```
1,5⌽9,
```
replicate numbers from 1 to 5, 1-2-3-2-1 times respectively 
```
(t←1 2 3 2 1)/⍳5
```
make 5 nested vectors of length 1-2-3-2-1 respectively
```
((t←1 2 3 2 1)/⍳5)⊆
```
transform numerical arrays into char vectors
```
⍕¨
```
nested vectors into matrix
```
↑
```
shift each line 1-2-3-2-1 positions to the left respectively, and then 2 more for every line
```
2⌽t⌽
```
[Answer]
# PHP, ~~83~~ 81 bytes
*83 bytes*
```
<?=($l=range(2,8))&&shuffle($l)?vsprintf("  1\n %d%2d\n%d 9 %d\n%2d%2d\n%3d",$l):0;
```
[Try it online!](https://tio.run/##K8go@P/fxt5WQyXHtigxLz1Vw0jHQlNTTa04ozQtLScVKK5pX1ZcUJSZV5KmoaSgYBiTp6CaomqUEpOnmqJgCWQDGUZQAeMUJR2gBisD6///AQ)
---
*81 bytes*
Splitting code into 2 fragments to save 2 characters. Thanks for the comment [@manatwork](https://codegolf.stackexchange.com/users/4198/manatwork).
```
<?$l=range(2,8);shuffle($l)?><?=vsprintf("  1\n %d%2d\n%d 9 %d\n%2d%2d\n%3d",$l);
```
[Try it online!](https://tio.run/##LctBCsMgEEDRq0iIYCBdxG5aEutFAiGgxoCMg056/E5cdPf48DEi82L7ZMoOh1d6fA1zjVcIyas@DfazWPOtWE6goDohphWEdFK7FaQT7@YG/Q9P141tmpl/GenMUPnhRI250JbRw0b7Yahc/gY)
[Answer]
# C (GCC) ~~161~~ 158 bytes
-3 bytes from ceilingcat
```
#define B,b[i++]
b[]=L"";main(a,t,i){srand(time(0));for(i=b;--i;b[a]=t)*b=b[a=rand(t=*b)%7];printf("  1\n %d %d\n%d 9 %d\n %d %d\n  %d"B B B B B B B);}
```
`L""` has non-printing characters that I can't get to show in SE is equivalent to `{2,3,4,5,6,7,8}`
this code makes the assumption that the address of `b` is at least 14 in order to guarantee all results are possible
[Try it online!](https://tio.run/##TYrNCgIhHMShb/YpxFjQXYU6RYiXPfcGrgddNf6HtTBv0bObFEHMMPNjmIlfp6mUvfMBokcDswr6XjdWaXnBi@VqvdnusJgNRGJYZkCfj2SiIxlmTw6UinBLBKQVnIOwymiZaWdlJfn9yc7S9qTFPUHMgWCEjmNEraseY63zB34DqokH9CcqXqW8AQ "C (gcc) – Try It Online")
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), ~~42~~ 32 bytes
```
`  1
 % %
% 9 %
 % %
  %`7ɾ1+Ṗ℅%
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%60%20%201%0A%20%25%20%25%0A%25%209%20%25%0A%20%25%20%25%0A%20%20%25%607%C9%BE1%2B%E1%B9%96%E2%84%85%25&inputs=&header=&footer=)
-10 thanks to lyxal.
[Answer]
# Java 10, ~~140~~ 139 bytes
```
v->{var r="  1\n x x\nx 9 x\n x x\n  x";for(int d=9,m=3;m<511;r=r.replaceFirst("x",d+""))for(;m==(m|=1<<(d*=Math.random()));d=9);return r;}
```
Port of [*@Arnauld*'s JavaScript answer](https://codegolf.stackexchange.com/a/197681/52210), so make sure to upvote him as well!
[Try it online.](https://tio.run/##dZA9T8MwEIb3/opXnmxoIiLUoXLcka1dkFgog0lScLGd6OJEQSW/PThNGVnudN/Pe2fd6@Rcfk2F1W2LvTb@sgKMDxWddFHhMIfAcyDjP1Dwl9qU6IWM2XEVTRt0MAUO8FBTn@wuvSaQYkB29BgwHP2A7eyWABiYPNXE4wmUart26lG6fJNlkhSlVDU2nn0y1AbOBrYu7xkTYh6QTinuflSW57y8U3sdPlPSvqwdF0LIuEtIqkJHHiTHSc50TfduI90Nsp/ZXZTIFzmvb9Bi0fdHZNRGwiTJ7kHiVoriv9tQubTuQtrEuWA992nBfWetuH7in6Zbbbz@apx@AQ)
**Explanation:**
```
v->{                // Method with empty unused parameter and String return-type
  var r="  1\n x x\nx 9 x\n x x\n  x";
                    //  Result-String, starting at:
                    //  "  1
                    //    x x
                    //   x 9 x
                    //    x x
                    //     x"
  for(int d=9,      //  Temp integer for the random digit, starting at 9
          m=3;      //  Bit-mask `m`, starting at 3 (binary 000000011)
          m<511     //  Loop as long as `m` is not 511 yet (binary 111111111):
          ;         //    After every iteration:
           r=r.replaceFirst("x",d+""))
                    //     Replace the first "x" with digit `d`
    for(;m==        //   Inner loop as long as `m` is unchanged after
            (m|=    //   `m` is bitwise-ORed with:
                1<< //    2 to the power
                   (d*=Math.random()));
                    //    a random digit in the range [0,9)
      d=9);         //     After every iteration: reset `d` to 9 again
  return r;}        //  And finally return the result-String
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 139 bytes
```
char a[7],c;r(){for(srand(time(0));c=rand()%7,a[c]++;);c+=2;}f(){printf("  1\n %d %d\n%d 9 %d\n %d %d\n  %d",r(),r(),r(),r(),r(),r(),r());}
```
Generates a random number 0-6, tests if that number has been generated before, and if not, prints it.
[Try it online!](https://tio.run/##lY3BCoMwDIbvPkUoCAk62HaREXwS66HEdevBKtXtIj57F4Qdd1hI/iQfJL@cHiI5y9MlcF3T18IJafNTwiW5OOAaxjueiVjaY6eyqV0nfVWxsqq98u71YE4hrh4NwMVGKAdNG7XdjuELQNXUavCriPesj2B0IeJ7CgMVWwEa6sEwv9YFjY2G@A@45w8 "C (gcc) – Try It Online")
]