Diagonalized alphabet
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.
BQN, 18 bytesSBCS ``` 'A'- …
3y ago
Canvas, 17 11 bytes Z2n⤢J …
3y ago
[Python 2], 61 bytes …
3y ago
Japt `-R`, 16 bytes This fe …
3y ago
[APL (Dyalog Unicode)], 31 byt …
3y ago
Ruby, 52 51 bytes 13.times{ …
3y ago
[C (clang)], 206 bytes …
3y ago
7 answers
Canvas, 17 11 bytes
Z2n⤢J{×7«mT
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
0 comment threads
BQN, 18 bytesSBCS
'A'-¬⊸⌊2×13-˜⌜○↕14
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
0 comment threads
Python 2, 61 bytes
i=12;exec"print'YWUSQOMKIGECABDFHJLNPRTVXZ'[i:14+i];i-=1;"*13
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 :)
Japt -R
, 16 bytes
This feels far too long for the task at hand - what am I missing?!
;Bó
v ¬£14îUiX q
;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
0 comment threads
APL (Dyalog Unicode), 31 bytes
⎕←↑(14↑(2⌷x),⍨⌽)¨,\1⌷x←⍉13 2⍴⎕A
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
Requires zero-indexing.
0 comment threads
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--);}
yez ai m gud progamer!11!
0 comment threads