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
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Diagonalized alphabet

+5
−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 comment threads

7 answers

+6
−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 comment threads

+5
−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 comment threads

+3
−0

Python 2, 61 bytes

i=12;exec"print'YWUSQOMKIGECABDFHJLNPRTVXZ'[i:14+i];i-=1;"*13

Try it online!

I tried to do it without writing the full list 'YWUSQOMKIGECABDFHJLNPRTVXZ' but couldn't get less than 61 bytes. Do not hesitate to give me advice :)

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

1 comment thread

just using while cuts down on some bytes (1 comment)
+2
−0

Japt -R, 16 bytes

This feels far too long for the task at hand - what am I missing?!

;Bó
v ¬£14îUiX q

Test it

;Bó\nv ¬£14îUiX q
;B                    :Uppercase alphabet
  ó                   :Uninterleave
   \n                 :Assign to variable U
     v                :Remove and return first element
       ¬              :Split
        £             :Map each X
         14î          :Slice the following to length 14
            UiX       :  Prepend X to U, modifying it
                q     :  Join
                      :Implicit output joined with newlines
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−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 comment threads

+1
−0

Ruby, 52 51 bytes

13.times{puts:YWUSQOMKIGECABDFHJLNPRTVXZ[12-_1,14]}

Attempt This Online!

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

0 comment threads

+0
−0

C (clang), 206 bytes

main(i){char*s="YWUSQOMKIGECABDFHJLNPRTVXZ";for(i=13;i>0;printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",s[-1+i],s[0+i],s[1+i],s[2+i],s[3+i],s[4+i],s[5+i],s[6+i],s[7+i],s[8+i],s[9+i],s[10+i],s[11+i],s[12+i]),i--);}

Try it online!

yez ai m gud progamer!11!

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

0 comment threads

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!

Like what we're doing? Support us! Donate