30
3
Introduction
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.
3Since there are 7! combinations, strictly you don't mean "A new rack MUST be generated on each run", merely "you cannot just produce a single randomly-chosen rack every time." – smci – 2020-01-05T14:46:29.243
8Should all possible outputs have nonzero probability? Or should they all be equally likely? – Luis Mendo – 2020-01-05T17:26:18.107
@smci yeah, that was what I meant. – nihilazo – 2020-01-06T16:54:48.747
@LuisMendo Doesn't really matter? Not sure honestly – nihilazo – 2020-01-06T16:55:22.830
3
@nihilazo It does matter. You need to specify what you allow. Otherwise people can for example pick between two possible outputs at random. Right now you only say it can't be just one output
– Luis Mendo – 2020-01-06T17:23:23.0531Okay let's require that the code be capable of generating all of the 7! possible results. (I don't see how requiring them to be equiprobable makes things harder, but someone might think of something) – smci – 2020-01-06T19:18:51.950
1I've been playing nine-ball casually for decades, and I've never seen anyone rack it in any order but the "right" one (your first example output). So while I now know they don't have be done that way, I doubt I'm going to throw them in any other order now :) – Geobits – 2020-01-06T21:15:41.220