Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users

Dashboard
Notifications
Mark all as read
Challenges

Diagonalized alphabet

+3
−0

Task

Print the following:

ABDFHJLNPRTVXZ
CABDFHJLNPRTVX
ECABDFHJLNPRTV
GECABDFHJLNPRT
IGECABDFHJLNPR
KIGECABDFHJLNP
MKIGECABDFHJLN
OMKIGECABDFHJL
QOMKIGECABDFHJ
SQOMKIGECABDFH
USQOMKIGECABDF
WUSQOMKIGECABD
YWUSQOMKIGECAB

and nothing else. You may return a multiline string or an array representing the box.

You may have trailing whitespace in your output if it is a multiline string.

This is code-golf. Shortest answer in bytes bins.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comments

3 answers

+4
−0

BQN, 18 bytesSBCS

'A'-¬⊸⌊2×13-˜⌜○↕14

Run online!

This solution computes a table of c-r, where r is the row number and c is the column number, so that the first row is 0 1 2… and the first column is 0 ¯1 ¯2…. After this it maps non-positive numbers 0 ¯1 ¯2… to A C E…, and positive ones 1 2… to B D…, using the arithmetic expanded below. BQN's extension of boolean negation ¬ to mean one minus the argument is helpful here.

'A'-¬⊸⌊2×13-˜⌜○↕14
         13     14  # Numbers
              ○↕    # Range of each
           -˜⌜      # Subtract-from table    0 ¯1 ¯2 /  1  2
       2×           # Times two              0 ¯2 ¯4 /  2  4
    ¬⊸              # 1 minus, then…         1  3  5 / ¯1 ¯3
      ⌊             # Minimum with original  0 ¯2 ¯4 / ¯1 ¯3
'A'-                # Subtract from 'A'      A  C  E /  B  D
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

+3
−0

Canvas, 17 11 bytes

Z2n⤢J{×7«mT

Try it here!

Z           The alphabet
 2n         split into pairs: ["AB","CD","EF",…]
   ⤢        transposed: ["ACEGI…","BDFHJ…"]
    J        remove and push the first item: ["BDFHJ…"], "ACEGI…"
     {       for each character of "ACEGI…"
      ×        prepend horizontally: "ABDFHJ…" → "CABDFHJ…" → …
       7«m     cut off everything after 14 chars
           T   print that, leaving the item on the stack for the next iteration
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

+1
−0

APL (Dyalog Unicode), 31 bytes

⎕←↑(14↑(2⌷x),⍨⌽)¨,\1⌷x←⍉13 2⍴⎕A

Try it online!

Lot worse than the BQN answer.

⎕←↑(14↑(2⌷x),⍨⌽)¨,\1⌷x←⍉13 2⍴⎕A
                              ⎕A ⍝ String of uppercase letters
                         13 2⍴   ⍝ Turn that into a matrix where the
                                 ⍝ first column is ACE... and the second is BDF...
                        ⍉        ⍝ Turn those columns into rows
                      x←         ⍝ Assign to x
                    1⌷            ⍝ Get the first row ('ACE...')
                   ,/            ⍝ Prefixes of that
                  ¨              ⍝ Map each prefix:
                ⌽                ⍝ Reverse it
              ,⍨                ⍝ And prepend it to
          (2⌷x)                  ⍝ The second row of x ('BDF...')
       14↑                       ⍝ Keep the first 14 letters
   ↑                            ⍝ Make it a matrix
⎕←                              ⍝ Print it (not totally necessary)

APL (Dyalog Unicode), 33 bytes

⎕←↑(⌽⍳13)(14↑↓)¨⊂↑,⍨∘⌽⍨/↓⍉13 2⍴⎕A

Try it online!

Requires zero-indexing.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!