11
\$\begingroup\$

The Miracle Octad Generator (MOG) introduced by R. T. Curtis in 1976 is a central tool in the study of sporadic groups, error-correcting codes, Steiner systems, and sphere-packings.

The MOG is basically a single diagram. See e.g.

for versions of the MOG and

Your task is to output the MOG in ASCII form.

One possible version of the required output is the following. This was generated by the method described at http://finitegeometry.org/sc/24/gentheog2.pdf (but with the 2x4 and 4x4 blocks together instead of separated).

X- X-O+
X- X-O+
X- X-O+
X- X-O+

X- X-O+
-X -X+O
X- X-O+
-X -X+O

X- X-O+
-X -X+O
-X -X+O
X- X-O+

XX XXOO
-- --++
-- --++
XX XXOO

X- X-O+
X- X-O+
-X -X+O
-X -X+O

XX XXOO
-- --++
XX XXOO
-- --++

XX XXOO
XX XXOO
-- --++
-- --++

-X XXXX
X- ----
X- OOOO
X- ++++

-- XOXO
XX XOXO
X- -+-+
-X -+-+

-- X+X+
-X O-O-
XX X+X+
X- O-O-

-X X+X+
-X +X+X
-- O-O-
XX -O-O

-- X-X-
X- +O+O
-X +O+O
XX X-X-

-X XOXO
-- -+-+
XX +-+-
-X OXOX

-X X-X-
XX O+O+
-X -X-X
-- +O+O

X- XX--
-X --XX
X- OO++
X- ++OO

X- XO-+
-X XO-+
-- -+XO
XX -+XO

X- X+-O
-- O-+X
-X X+-O
XX O-+X

XX X+-O
-- +XO-
-X O-+X
-X -OX+

XX X--X
X- +OO+
-X +OO+
-- X--X

XX XO-+
X- -+XO
X- +-OX
-- OX+-

X- X--X
XX O++O
X- -XX-
-- +OO+

X- XXOO
X- --++
-X OOXX
X- ++--

XX XOOX
-- XOOX
X- -++-
-X -++-

X- X+O-
XX O-X+
-X X+O-
-- O-X+

XX X+O-
-- +X-O
X- O-X+
X- -O+X

X- X-O+
XX +O-X
-- +O-X
-X X-O+

X- XOOX
-- -++-
XX +--+
X- OXXO

XX X-O+
-X O+X-
-- -X+O
-X +O-X

X- XX++
X- --OO
X- OO--
-X ++XX

X- XO+-
-X XO+-
XX -+OX
-- -+OX

XX X++X
-X O--O
-- X++X
X- O--O

X- X++X
X- +XX+
-- O--O
XX -OO-

X- X-+O
-- +OX-
XX +OX-
-X X-+O

XX XO+-
-X -+OX
-X +-XO
-- OX-+

XX X-+O
X- O+-X
-- -XO+
X- +OX-

Details

The output should consist of 35 6-by-4 rectangles of symbols, each split horizontally into a 2-by-4 rectangle (the brick) and a 4-by-4 square (the square), separated by a single vertical column of spaces, as above. The 35 rectangles themselves should be separated by single blank lines. Trailing spaces and up to one trailing blank line are allowed.

Each brick and square is solidly packed with symbols. You can choose any 2 consistent printable non-whitespace ASCII characters for the symbols that appear in the bricks (X,- here) and any 4 printable non-whitespace characters for the squares (X,-,+,O here). The 2 characters can be a subset of the 4 characters (as here), or not.

Symbols like those above that look nice and are easy to distinguish at a glance are encouraged but not required.

The symbols represent a partition of the brick and a partition of the square (both into sets of size 4). Within each brick you can optionally exchange the roles of the 2 symbols, and within each square you can permute the 4 symbols. Otherwise, each 6-by-4 rectangle should exactly match exactly one of those listed above. Permuting the locations within the brick and square is not allowed.

The 35 6-by-4 rectangles can appear in any order. The pairing between bricks and squares cannot be changed.

The output should not be transposed or otherwise reshaped.

Nothing else should be output, and the code should not throw errors.

It is not required (or allowed) to arrange the rectangles in a 5x7 array, or output the additional "key" rectangle included in some published versions, or draw fancy boxes, etc. (But non-competing answers that do such things might be of independent interest).

Brute-force algorithms that would never finish in practice are allowed, but sensibly efficient algorithms may be more interesting.

As an alternative to printing the output, it is acceptable to output a string including newlines.

This is , so shortest solution in each language wins.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Consider adding the tag ascii-art \$\endgroup\$
    – Luis Mendo
    Commented Aug 23 at 15:07
  • \$\begingroup\$ Not sure if that's a problem, but the output provided in the challenge is not exactly what is described in gentheog2.pdf. The second 2x4 block of the first row is different (and so are all 2x4 blocks derived from it, obviously). \$\endgroup\$
    – Arnauld
    Commented Aug 25 at 15:24
  • 1
    \$\begingroup\$ @Arnauld This should not be a problem, because you are allowed to swap the roles of the two symbols within any block. (To me the challenge version seems more logical). \$\endgroup\$
    – aeh5040
    Commented Aug 26 at 17:07
  • 1
    \$\begingroup\$ @Luis Mendo "But is it art?" Ok, you have convinced me! \$\endgroup\$
    – aeh5040
    Commented Aug 26 at 17:08

4 Answers 4

9
\$\begingroup\$

JavaScript (ES6), 165 bytes

Returns a string with newlines, using the symbols suggested in the challenge.

f=(p=5)=>p--?(g=(k,b,h=i=>i>23?`
`+g(k,h):"X-O+"[x=i%6,y=i/6,h[i++]=b?b[3*(y*25&6)+x^y&1]:p>3?57%~x:[p!=~~y,y,p^y][x>>1]^!x]+[` 
`[~-x/4]]+h(i))=>k--?h``:f(p))(7):""

Try it online!

Generating the main patterns

Below are the 5 main patterns which are generated in this order, from \$p=4\$ to \$p=0\$:

main patterns

Each row in the first pattern is filled with the sequence 0,1,0,1,2,3 which is obtained with the formula 57 % ~x.

For the other patterns:

  • the cells of the 1st column are set to \$1\$ if \$y=p\$ or \$0\$ otherwise
  • each cell in the 2nd column is the complement of its neighbor in the 1st column
  • the next 2 columns are set to \$y\$
  • the last 2 columns are set to \$y\operatorname{xor} p\$

Deriving the other patterns

The other patterns are generated by applying the following transformation 6 times:

$$\begin{pmatrix}a&b&\color{blue}i&\color{blue}j&\color{green}q&\color{green}r\\c&d&\color{blue}k&\color{blue}l&\color{green}s&\color{green}t\\e&f&\color{blue}m&\color{blue}n&\color{green}u&\color{green}v\\g&h&\color{blue}o&\color{blue}p&\color{green}w&\color{green}x\end{pmatrix}\rightarrow\begin{pmatrix}a&f&\color{blue}i&\color{blue}n&\color{green}q&\color{green}v\\b&e&\color{blue}j&\color{blue}m&\color{green}r&\color{green}u\\c&h&\color{blue}k&\color{blue}p&\color{green}s&\color{green}x\\d&g&\color{blue}l&\color{blue}o&\color{green}t&\color{green}w\end{pmatrix}$$

A pattern is internally stored as a flat array, filled by reading the elements of the matrix from left to right and top to bottom.

Therefore, the actual transformation is processed by filling the target array with the elements at the following positions from the source array:

[ 0, 13, 2, 15, 4, 17, 1, 12, 3, 14, 5, 16, 6, 19, 8, 21, 10, 23, 7, 18, 9, 20, 11, 22 ]

This sequence is obtained with:

$$a_i=\left(3\times\left(\left\lfloor\frac{i\times25}{6}\right\rfloor\operatorname{and}6\right)+(i\bmod 6)\right)\operatorname{xor}\left(\left\lfloor \frac{i}{6} \right\rfloor\bmod 2\right)$$

Or in JS, with x = i % 6 and y = i / 6:

3 * (y * 25 & 6) + x ^ y & 1
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Out of interest I checked and it takes Charcoal 155 bytes to output your program, so not quite the Miracle Miracle Miracle Octad Generator Generator Generator than I'd hoped... \$\endgroup\$
    – Neil
    Commented Aug 25 at 14:03
  • \$\begingroup\$ No, I was being tongue-in-cheek, since I was trying to generate your program that generates the MOG... \$\endgroup\$
    – Neil
    Commented Aug 26 at 9:29
  • \$\begingroup\$ Oh ... I see. ^^ \$\endgroup\$
    – Arnauld
    Commented Aug 26 at 9:36
9
\$\begingroup\$

Jelly,  65 60  59 bytes

-3 leading to two three more thanks to emanresu A (join with spaces, giving blank lines a trailing space).

Whew!

4R8œ?$ṚƭƬ;"`p`ḣ4Jx4ṁƲ;$Q“ṅ⁷ṆŻ§‘Bp⁶¤;"œ?@€€Ƭ⁽¥ọẎŒH€Z€zɗ€⁶KYF

A full program that takes no input and prints the combined bricks and squares of the MOG as they appear in:

MOG

in row-major order, using:

  • 0 (white) and 1 (black) in the bricks and
  • 1-4 (black, white, circle, dot) in the squares.

Blank lines each have a single, trailing space character.

Try it online!

How?

First, build the four rightmost squares of the top row with each in column-major order split into two:

4R8œ?$ṚƭƬ;"`p`ḣ4
4R               - range 4 -> [1,2,3,4]
        Ƭ        - collect up while distinct, applying:
       ƭ         -   in turn:
     $           -   a) last two links as a monad:
  8              -        get the eighth
   œ?            -        lexicographic permutation
      Ṛ          -   b) reverse
           `     - use {that} as both arguments of:
          "      -   zip with:
         ;       -     concatenate
             `   - use {that} as both arguments of:
            p    -   Cartesian product
              ḣ4 - keep the first four

Now prefix that with the top-left square in the same format:

Jx4ṁƲ;$Q
      $  - last two links as a monad - f(TopRightSquares):
    Ʋ    -   last four links as a monad:
J        -     indices -> [1,2,3,4]
  4      -     four
 x       -     times -> [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4]
   ṁ     -     mould like {TopRightSquares}
     ;   -   concatenate {TopRightSquares}
       Q - deduplicate

Now add the top five blocks to their respective squares:

“ṅ⁷ṆŻ§‘Bp⁶¤;"
          ¤   - nilad followed by link(s) as a nilad: 
“ṅ⁷ṆŻ§‘       -   Code-page indices -> [240,135,180,210,225]
       B      -   convert to binary
        p⁶    -   Cartesian product with a space character
                    (this a seed for the column of spaces, later)
            " - zip with {TopFiveSquares} with:
           ;  -   concatenate

Now add the other twenty-eight blocks and squares using the five constructed so far:

œ?@€€Ƭ⁽¥ọẎ
     Ƭ     - collect up while distinct, applying:
   €€      -   for each {TwoColumnList} of each {Block&Square}:
œ?@   ⁽¥ọ  -     2222nd lexicographic permutation
         Ẏ - tighten to a list of the 35 Block&Squares

Now reformat and print:

ŒH€Z€zɗ€⁶KYF
        ⁶    - space character
      ɗ€     - last three links for each as a dyad - f(Block&Square, SpaceCharacter)
ŒH€          -   split each into two
   Z€        -   transpose each
     Z       -   transpose
      z      -   transpose with filler {SpaceCharacter}
                   (extending the single space from the `,€⁶`, earlier, to a column)
         K   - join with space characters
          Y  - join with newline characters
           F - flatten
             - implicit print
\$\endgroup\$
4
  • \$\begingroup\$ I think this formatting works for 62? \$\endgroup\$
    – emanresu A
    Commented Aug 25 at 7:19
  • \$\begingroup\$ Yep, looks to adhere to the rules, thanks! Shaved two more (K and a sneaky use of z). \$\endgroup\$ Commented Aug 25 at 20:20
  • \$\begingroup\$ You seem to have not updated your TIO link? \$\endgroup\$
    – emanresu A
    Commented Aug 25 at 22:22
  • \$\begingroup\$ Oops, have done so now. \$\endgroup\$ Commented Aug 25 at 23:57
3
\$\begingroup\$

APL+WIN, 225 bytes

i←1 6 2 5 3 8 4 7
a←b←'X-X-X-X-'⋄c←'O+O+O+O+'
r←'((4 2⍴a),'' '',(4 2⍴b),(4 2⍴c))⍪'' ''⋄'
s←r,∊6⍴⊂'a←a[i]⋄b←b[i]⋄c←c[i]⋄',r
⍎s
x←a←'X--X-X-X'⋄c←b←d←'XX--OO++'
⍎s
y←a←'X--XX-X-'⋄b←d⋄c←4⌽⌽d
⍎s
a←6⌽y⋄b←d⋄c←4⌽d
⍎s
a←⌽x⋄b←d⋄c←⌽d
⍎s

Try it online! Thanks to Dyalog Classic

Explanation by row of the function

[1] assign the indices to do the Singer 7-cycle as described in the example link

[2] assign the first main brick, the first 2 columns and the second 2 columns of the first main block as 8 element vectors

[3] format the output in the required form

[4] define the code to carry out the Singer 7-cycle for the first main brick and block and the 6 bricks and blocks under them and output the results

[5]execute that code

[6-13] repeat [2] and [5] for each main brick and block in turn with some attempt to golf the input vectors

\$\endgroup\$
3
\$\begingroup\$

Charcoal, 87 bytes

⊞υ⭆+O-X-X×⁴ιF⁴⊞υ⁺⭆¹⁶§X-O+⎇›κ⁷κ⁻|κι&κι⭆²⭆⁴§-X⁼¬ι⁼κ⁼μιF³⁵«⊞υ⭆⪪§υι⁸⭆⁸§κ⊘⁺⁴×⁹μ↓⪪⪪§υι⁴¦⁴M⁸¦⁵

Try it online! Link is to verbose version of code. Explanation: Uses the method of the linked PDF but outputs the results in row-major rather than column-major order.

⊞υ⭆+O-X-X×⁴ι

Each block is represented by 24 characters as viewed with a 90° rotation, so the first block is ++++OOOO----XXXX----XXXX.

F⁴⊞υ⁺⭆¹⁶§X-O+⎇›κ⁷κ⁻|κι&κι⭆²⭆⁴§-X⁼¬ι⁼κ⁼μι

Generate the next four blocks.

F³⁵«

Repeat for each of the 35 octads.

⊞υ⭆⪪§υι⁸⭆⁸§κ⊘⁺⁴×⁹μ

Generate the n+5th octad by splitting the current octad into groups of 8, then within each group cyclically taking every th character starting at the third.

↓⪪⪪§υι⁴¦⁴

Output the current octad, but pretty-printed and rotated.

M⁸¦⁵

Move to where the next octad is to be printed.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.