24
\$\begingroup\$

Without taking any input, output this exact text:

                         A
                        B A
                       C B A
                      D C B A
                     E D C B A
                    F E D C B A
                   G F E D C B A
                  H G F E D C B A
                 I H G F E D C B A
                J I H G F E D C B A
               K J I H G F E D C B A
              L K J I H G F E D C B A
             M L K J I H G F E D C B A
            N M L K J I H G F E D C B A
           O N M L K J I H G F E D C B A
          P O N M L K J I H G F E D C B A
         Q P O N M L K J I H G F E D C B A
        R Q P O N M L K J I H G F E D C B A
       S R Q P O N M L K J I H G F E D C B A
      T S R Q P O N M L K J I H G F E D C B A
     U T S R Q P O N M L K J I H G F E D C B A
    V U T S R Q P O N M L K J I H G F E D C B A
   W V U T S R Q P O N M L K J I H G F E D C B A
  X W V U T S R Q P O N M L K J I H G F E D C B A
 Y X W V U T S R Q P O N M L K J I H G F E D C B A
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

Rules

  • Output can be given by any convenient method.
  • You can print it to STDOUT or return it as a function result.
  • Either a full program or a function are acceptable.
  • A single trailing newline is acceptable, but no other formatting changes are allowed.
  • Capital letters are required.
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
\$\endgroup\$
  • 2
    \$\begingroup\$ A single trailing newline is acceptable, but no other formatting changes are allowed. So a trailing space on each line would not be permitted? \$\endgroup\$ – DJMcMayhem Oct 25 at 18:04
  • 2
    \$\begingroup\$ @DJMcMayhem Correct - no trailing spaces. Darn that rules out [char][space] times length, doesn't it? ;-) \$\endgroup\$ – AdmBorkBork Oct 25 at 18:05
  • \$\begingroup\$ Can we return a list of strings? \$\endgroup\$ – Nick Kennedy Oct 25 at 18:41
  • 2
    \$\begingroup\$ @NickKennedy Yes, that's fine. \$\endgroup\$ – AdmBorkBork Oct 25 at 18:47
  • 1
    \$\begingroup\$ I like the 3d bump effect around the J. \$\endgroup\$ – Eric Duminil Oct 27 at 13:22

48 Answers 48

1
\$\begingroup\$

Forth (gforth), 62 bytes

: f 25 for i spaces 25 i - for i 65 + emit ."  "next cr next ;

Try it online!

Code explanation

: f            \ start a new word definition
  25 for       \ loop from 25 to 0
    i spaces   \ print loop-index spaces
    25 i - for \ loop from (25 - loop-index) to 0
      i 65 +   \ add inner loop-index to 65 (ascii 'A')
      emit     \ output ascii char for value
      ."  "    \ output a single space
    next       \ end inner loop
    cr         \ output a newline
  next         \ end outer loop
;              \ end word definition
\$\endgroup\$
1
\$\begingroup\$

R, 65 bytes

for(i in 1:26){cat(strrep(" ",26-i));cat(LETTERS[i:1]);cat("\n")}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

J, 31 bytes

(|.@;:inv,~' '#~26-#)\u:65+i.26

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Julia 1.0, 51 bytes

[' '^i*join(('Z'-i:-1:'B').*' ')*'A' for i=25:-1:0]

Try it online!

\$\endgroup\$
1
\$\begingroup\$

APL (Dyalog Extended), 22 bytes

(⌽0,⍳25)⌽⌽↑{∊⍺' '⍵}\⎕A

Try it online!

Output of above function.

Explanation:

  • ⎕A is the uppercase alphabet character vector.
  • {∊⍺' '⍵} is a 1 character shorter version of {⍺,' ',⍵} which puts a space between arguments and .
  • Reducing / this function over ⎕A would result in the uppercase alphabet with spaces between, 'A B C ...'. Scanning \ instead produces a nested vector of all the intermediate results, ('A') ('A B') ('A B C')....
  • Mix turns the nested vector into a matrix, padding rows to equal length with spaces, which is then horizontally mirrored with (the one on the right).
  • To get the final answer we need to rotate the rows (dyadic ) by 25, 24, 23, ... 0 characters.
  • The left argument to the rotation is the sequence 25, 24, 23, ... 0, which is obtained concisely by ⌽0,⍳25.
\$\endgroup\$
0
\$\begingroup\$

Jelly, 16 bytes

L26_⁶x;KU$
ØAÇƤY

Try it online!

This seems too long for Jelly, despite being terrible at challenges

\$\endgroup\$
0
\$\begingroup\$

Zsh, 46 bytes

for c ({A..Z})a=($c $a)&&echo ${(l:25-i++:)}$a

Try it online!

Abuses arrays implicitly joining on spaces. l:expr: pads on the left with spaces until at expr characters wide. Putting parameter expansion flags with no parameter like this causes them to operate on an empty string.


Alternate 46 byte solution, using a string with ${a%postfixremoval} instead. Note that here we increment the padding width to accommodate the growing total string length.

for c ({A..Z})a=$c\ $a&&echo ${(l:26+i++:)a%?}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Haskell, 63 bytes

[(' '<$[c..'Y'])++foldl(\s->(:' ':s))"A"['B'..c]|c<-['A'..'Z']]

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Japt, 29 bytes

;1o27@Bt0X)w)ò1)qS)ùS25+X})qR

Try it online!

\$\endgroup\$
  • \$\begingroup\$ This can be done in 11 bytes ;) Hint: it involves cumulative reduction. \$\endgroup\$ – Shaggy Oct 26 at 1:37
  • \$\begingroup\$ @Shaggy Did I get your 11 byte solution? \$\endgroup\$ – Embodiment of Ignorance Oct 26 at 5:44
  • \$\begingroup\$ Seeing as @EmbodimentofIgnorance got that, you can still golf this one to 17 bytes \$\endgroup\$ – Shaggy Oct 26 at 9:30
0
\$\begingroup\$

PHP, 59 bytes

for($a=A;$i++<26;)echo str_pad('',26-$i),$s=$a++." $s","
";

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Wren, 125 119 bytes

Not very interesting until I read other answers.

for(i in 0..25){
System.write(" "*(25-i))
for(j in 0..i)System.write(" "+String.fromCodePoint(65+i-j))
System.print()
}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Elixir, 70 bytes

r=90..65;for i<-0..25,do: IO.puts for j<-r,do: 65+i-j>-1&&[j,' ']||' '

Try it here

\$\endgroup\$
0
\$\begingroup\$

Javascript ES6, 105 bytes

[..."ZYXWVUTSRQPONMLKJIHGFEDCBA"].forEach((l,i,a)=>console.log(" ".repeat(25-i)+a.slice(25-i).join(" ")))

\$\endgroup\$
0
\$\begingroup\$

Java (JDK), 84 bytes

v->{var x="A";for(char c=65;++c<92;x=c+" "+x)System.out.printf("%"+(c-40)+"s%n",x);}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

sed 4.2.2 (with GNU exec extension), 58 bytes

s/^/bash -c 'echo {Z..A}'/e
:
s/^( *)\S([^\n]+)/\1\2\n&/
t

Try it online!


Pure sed 4.2.2, 71 bytes

s/^/ZYXWVUTSRQPONMLKJIHGFEDCBA/
s/\B/ /g
:
s/^( *)\S([^\n]+)/\1\2\n&/
t

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Perl 5, 30 bytes

$b[26+--$i]=$_,say"@b"for A..Z

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Python 3, 133 130 125 123 122 bytes

Not the shortest, but I wanted to try to make the output one single string

print('\n'.join((25-len(v)//2)*' '+v for v in(''.join(" "+chr(i)for i in range(90,64,-1))[i:52]for i in range(51,-1,-2))))

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Jelly, 12 bytes

ØAa⁶ḊÐƤżKƤUY

A full program which prints the result

Try it online!

How?

ØAa⁶ḊÐƤżKƤUY - Main Link: no arguments
ØA           - (set left to) uppercase alphabet  say:['A','B','C']
   ⁶         - space character                       ' '
  a          - AND (vectorises)                      [' ',' ',' ',]
     ÐƤ      - for postfixes:
    Ḋ        -   dequeue                             [[' ',' '],[' '],[]]
         Ƥ   - for prefixes (of left=alphabet):
        K    -   join with spaces                    [['A'],['A',' ','B'],['A',' ','B',' ','C']]
       ż     - zip together                          [[[' ',' '],['A']],[[' '],['A',' ','B']],[[],['A',' ','B',' ','C']]]
          U  - upend                                 [[[' ',' '],['A']],[[' '],['B',' ','A']],[[],['C',' ','B',' ','A']]]
           Y - join with newlines                    [[' ',' '],['A'],'\n',[' '],['B',' ','A'],'\n',[],['C',' ','B',' ','A']]
             - implicit, smashing print >>>  A
             -                          >>> B A
             -                          >>>C B A 
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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