73
\$\begingroup\$

Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text:

                         ZYXWVUTSRQPONMLKJIHGFEDCBA
                        YXWVUTSRQPONMLKJIHGFEDCBA
                       XWVUTSRQPONMLKJIHGFEDCBA
                      WVUTSRQPONMLKJIHGFEDCBA
                     VUTSRQPONMLKJIHGFEDCBA
                    UTSRQPONMLKJIHGFEDCBA
                   TSRQPONMLKJIHGFEDCBA
                  SRQPONMLKJIHGFEDCBA
                 RQPONMLKJIHGFEDCBA
                QPONMLKJIHGFEDCBA
               PONMLKJIHGFEDCBA
              ONMLKJIHGFEDCBA
             NMLKJIHGFEDCBA
            MLKJIHGFEDCBA
           LKJIHGFEDCBA
          KJIHGFEDCBA
         JIHGFEDCBA
        IHGFEDCBA
       HGFEDCBA
      GFEDCBA
     FEDCBA
    EDCBA
   DCBA
  CBA
 BA
A
  • The first line will have 25 spaces, then the alphabet backwards starting from the 26th letter (ZYXWVUTSRQPONMLKJIHGFEDCBA), then a newline.
  • The second line will have 24 spaces, then the alphabet backwards starting from the 25th letter (YXWVUTSRQPONMLKJIHGFEDCBA), then a newline.
  • ...
  • The last (26th) line will have no spaces, then the alphabet backwards starting from the 1st letter (A), then a newline.

Additional rules:

  • Your program may use any allowed output methods.
  • One trailing newline and/or one leading newline is allowed.
  • There must be one newline between lines containing the letters, no more.
  • The letters must be all uppercase.

As with , the shortest submission wins. Good luck!

Leaderboard:

var QUESTION_ID=141725,OVERRIDE_USER=61563;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
7
  • 4
    \$\begingroup\$ To me it looks like the light cast by the bat-signal \$\endgroup\$
    – scottinet
    Sep 5, 2017 at 19:47
  • 4
    \$\begingroup\$ Closely Related. \$\endgroup\$
    – Mr. Xcoder
    Sep 5, 2017 at 20:26
  • \$\begingroup\$ Can each line have an extra space in front of it? \$\endgroup\$
    – hyper-neutrino
    Sep 5, 2017 at 20:35
  • 3
    \$\begingroup\$ Could each line have trailing spaces after the last letter? \$\endgroup\$
    – miles
    Sep 5, 2017 at 20:49
  • 1
    \$\begingroup\$ @miles yes, that's fine. \$\endgroup\$
    – MD XF
    Sep 5, 2017 at 21:34

116 Answers 116

22
\$\begingroup\$

R, 67 55 bytes

for(i in 26:1)cat(rep(" ",i-1),LETTERS[i:1],"
",sep="")

Try it online!

\$\endgroup\$
7
  • 4
    \$\begingroup\$ R is beating Python on a string challenge? Nice. +1 for LETTERS \$\endgroup\$ Sep 6, 2017 at 10:00
  • 2
    \$\begingroup\$ @CriminallyVulgar it's a very weird challenge; Haskell is beating the tie of PHP and R which are both beating Python... at least Perl is ahead of all of them like you might expect. \$\endgroup\$
    – CR Drost
    Sep 8, 2017 at 20:13
  • \$\begingroup\$ -2 bytes if you change sep to s. Functions will autocomplete named arguments if there aren't collisions \$\endgroup\$ Mar 30, 2018 at 17:12
  • 1
    \$\begingroup\$ @Punintended that won't work because of the ... argument; arguments that come before ... (typically) get partial matched, and those after don't. I believe there are a few exceptions but cat isn't one of them \$\endgroup\$
    – Giuseppe
    Mar 30, 2018 at 17:30
  • \$\begingroup\$ @Giuseppe I don't see a ... \$\endgroup\$
    – MilkyWay90
    Jun 13, 2019 at 21:09
20
\$\begingroup\$

05AB1E, 7 bytes

Code:

₂žp.s1Λ

Uses the 05AB1E encoding. Try it online!

Explanation

 žp.s      # Get the suffixes of ZYX...CBA
      Λ    # Using the canvas mode, print the
₂          # first 26 elements of the array
     1     # into the upper-right direction
\$\endgroup\$
12
  • 2
    \$\begingroup\$ @MDXF IMO, that's a really dumb rule \$\endgroup\$
    – DJMcMayhem
    Sep 5, 2017 at 20:20
  • 3
    \$\begingroup\$ Hmm... I guess I'll remove the rule, then. status-completed \$\endgroup\$
    – MD XF
    Sep 5, 2017 at 20:22
  • 7
    \$\begingroup\$ Why does žp exist when Au is golden? BADUM tissss \$\endgroup\$ Sep 6, 2017 at 17:44
  • 5
    \$\begingroup\$ Using 05AB1E, create a file documenting all of it's features, shortes code wins :P \$\endgroup\$
    – Christian
    Sep 8, 2017 at 8:30
  • 3
    \$\begingroup\$ @Christian at one point an empty program printed this haha. Edit, it still does xD. \$\endgroup\$ Jan 31, 2018 at 18:25
17
\$\begingroup\$

Python 2, 57 bytes

i=26
while i:i-=1;print' '*i+bytearray(range(65+i,64,-1))

Try it online!

\$\endgroup\$
16
\$\begingroup\$

V, 13, 11 bytes

¬ZAòY>HGpxl

Try it online!

Hexdump:

00000000: ac5a 41f2 593e 4847 7078 6c              .ZA.Y>HGpxl

Written from my phone :P.

¬ZA         " Insert the alphabet backwards
   ò        " Recursively:
    Y       "   Yank this current line
     >H     "   Add one space to every line
       G    "   Move to the last line in the buffer
        p   "   Paste the line we yanked
         x  "   Delete one character
          l "   Move one character to the right, which will throw an error on 
            "   the last time through, breaking the loop
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I do these on my phone too, +1 \$\endgroup\$
    – Stan Strum
    Sep 5, 2017 at 22:45
13
\$\begingroup\$

PowerShell, 42 bytes

25..0|%{' '*$_+-join[char[]]((65+$_)..65)}

Try it online!

Explanation:

25..0|%{                                 } # Loop from 25 to 0
                             (65+$_)..65   # Construct a range of the specific ASCII codes
                    [char[]](           )  # Cast that as a character array
               -join                       # that has been joined together into a string
        ' '*$_+                            # Prepended with the correct amount of spaces
\$\endgroup\$
11
\$\begingroup\$

Bash + GNU sed, 60

printf %s {Z..A}|sed 'h
s/./ /g
G
s/ \n//
:x
p
s/ \S//
tx
d'

Try it online.

\$\endgroup\$
1
  • \$\begingroup\$ You can save two bytes by changing :x to : and tx to t. \$\endgroup\$
    – Jordan
    Oct 30, 2017 at 1:02
10
\$\begingroup\$

///, 105 97 bytes

/:/\\\\*//#/: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//\\*/\/\/_____#
\/ //_/     //*#

Try it online!

Explanation

/// only knows one command, /<pattern>/<substitution>/<text> replaces all occurrences of <pattern> in <text> with <substitution>. Additionally \ can be used to escape characters.

Shortened code for simplicity:

/:/\\\\*//#/:E:D:C:B:A//\\*/\/\/__#
\/ //_/  //*#

The first command /:/\\\\*/ replaces : with \\* in the subsequent code. This gives:

/#/\\*E\\*D\\*C\\*B\\*A//\\*/\/\/__#
\/ //_/  //*#

Then /#/\\*E\\*D\\*C\\*B\\*A/ replaces # with \*E\*D\*C\*B\*A:

/\\*/\/\/__\*E\*D\*C\*B\*A
\/ //_/  //*\*E\*D\*C\*B\*A

Then /\\*/\/\/__\*E\*D\*C\*B\*A<newline>\/ / replaces \* with //__*E*D*C*B*A<newline>/:

/_/  //*//__*E*D*C*B*A
/ E//__*E*D*C*B*A
/ D//__*E*D*C*B*A
/ C//__*E*D*C*B*A
/ B//__*E*D*C*B*A
/ A

Notice: I had to use \* for replacement. Since * is also part of the substitution, it would generate an infinite loop if I only replace *.

Then command /_/ / replaces _ with spaces, and /*// deletes all *:

EDCBA
/ E//    EDCBA
/ D//    EDCBA
/ C//    EDCBA
/ B//    EDCBA
/ A

The next command /#// replaces # by nothing. Since there is no # in the code, it does nothing. This is just here to remove the two leadings // from the beginning of the code. This leaves

EDCBA
/ E//    EDCBA
/ D//    EDCBA
/ C//    EDCBA
/ B//    EDCBA
/ 

Then the command / E// removes <space>E, so this will leave the code

    EDCBA
   DCBA
/ D//   DCBA
/ C//   DCBA
/ B//   DCBA
/ 

Similar / D// removes <space>D:

    EDCBA
   DCBA
  CBA
/ C//  CBA
/ B//  CBA
/ 

/ C//:

    EDCBA
   DCBA
  CBA
 BA
/ B// BA
/ 

/ B//:

    EDCBA
   DCBA
  CBA
 BA
A
/ 

And the last command is incomplete, so it does nothing:

    EDCBA
   DCBA
  CBA
 BA
A
\$\endgroup\$
1
  • \$\begingroup\$ Same lengths as the C# and brainfuck answers :D \$\endgroup\$ Sep 7, 2017 at 0:30
9
\$\begingroup\$

Haskell, 53 52 bytes

f(a:b)=(b>>" ")++a:b++'\n':f b
f x=x
f['Z','Y'..'A']

Try it online!

How it works

f['Z','Y'..'A']        -- call f with the full backwards alphabet

f(a:b)=                -- let `a` be the first char and `b` the rest. Return
   (b>>" ") ++         -- replace each char in b with a space, followed by
   a:b ++              -- the input string, followed by
   '\n' :              -- a newline, followed by
   f b                 -- a recursive call of `f` with `b`
f x=x                  -- stop on an empty input string
\$\endgroup\$
3
  • \$\begingroup\$ Why doesn't f['Z'..'A'] work? \$\endgroup\$ Sep 6, 2017 at 10:49
  • 1
    \$\begingroup\$ @ConorO'Brien: [a..b] starts with a and collects all the successors (+1 for integers, next ascii-char for characters, etc.) up to b. If a > b this is an empty list. However, you can specify also the second value (which can be smaller) from which an increment/decrement is calculated. [1,3..8] -> [1,3,5,7], [15,10..0] -> [15,10,5,0], or ['Z','Y'..'A'] which is the backwards uppercase alphabet. \$\endgroup\$
    – nimi
    Sep 6, 2017 at 16:09
  • \$\begingroup\$ Ah, I see now. Thanks! \$\endgroup\$ Sep 6, 2017 at 18:19
8
\$\begingroup\$

Python 2, 66 64

i=26
while i:i-=1;print' '*i+'ZYXWVUTSRQPONMLKJIHGFEDCBA'[25-i:]

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Welcome to Programming Puzzles & Code Golf - nice first answer! \$\endgroup\$
    – MD XF
    Sep 5, 2017 at 20:43
  • 2
    \$\begingroup\$ Thanks! Figured I'd give it a try instead of just lurking. \$\endgroup\$ Sep 5, 2017 at 20:45
  • 2
    \$\begingroup\$ You can remove the space between print and ' for 65 bytes. \$\endgroup\$
    – Mr. Xcoder
    Sep 5, 2017 at 20:48
  • \$\begingroup\$ I ported your answer into Pyth, take a look: codegolf.stackexchange.com/a/141939/63757 \$\endgroup\$
    – Stan Strum
    Sep 7, 2017 at 2:40
7
\$\begingroup\$

JavaScript (ES6), 83 77 76 bytes

f=(n=0,p='')=>n<26?f(++n,p+' ')+p+`ZYXWVUTSRQPONMLKJIHGFEDCBA
`.slice(~n):''

o.innerText = f()
<pre id=o>

\$\endgroup\$
2
  • \$\begingroup\$ I had wanted to suggest you an improvement, but then I realized that our approaches are very different. Hope you don't mind. \$\endgroup\$
    – user72349
    Sep 5, 2017 at 21:16
  • \$\begingroup\$ @ThePirateBay No problem! \$\endgroup\$
    – Arnauld
    Sep 5, 2017 at 21:17
7
\$\begingroup\$

brainfuck, 105 bytes

++++++++[>+>+++++++++++>++++>+++<<<<-]>++>++>>++[[->+>+<<]>-[-<<.>>]>[-<<<<.->>>+>]<-[-<+<<+>>>]<<<<.>>>]

Try it online!

Minified and formatted:

++++++++[>+>+++
++++++++>++++>+
++<<<<-]>++>++>
>++[[->+>+<<]>-
[-<<.>>]>[-<<<<
.->>>+>]<-[-<+<
<+>>>]<<<<.>>>]

Readable version:

[
  pre-initialize the tape with the values 10 90 32 >26<
  C_NEWLINE: 10
  V_ALPHA: 90
  C_SPACE: 32
  V_COUNTER: 26

AS:

  10 = 8 *  1 + 2
  90 = 8 * 11 + 2
  32 = 8 *  4 + 0
  26 = 8 *  3 + 2
]

8 ++++++++ [
  *  1 >+
  * 11 >+++++++++++
  *  4 >++++
  *  3 >+++
<<<<-]
PLUS 2 >++
PLUS 2 >++
PLUS 0 >
PLUS 2 >++

UNTIL V_COUNTER == 0 [
  COPY V_COUNTER to RIGHT and RIGHT_RIGHT
  [->+>+<<]
  TAPE: 10 V_ALPHA 32 >0< V_COUNTER_R V_COUNTER_RR
  V_COUNTER_R SUB 1 TIMES: >-[-
     PRINT C_SPACE <<.
  >>]
  TAPE: 10 V_ALPHA 32 0 >0< V_COUNTER_RR
  V_COUNTER_RR TIMES: >[-
    PRINT V_ALPHA <<<<.
    DECREMENT V_ALPHA -
    INCREMENT V_COUNTER_R >>>+
  >]
  TAPE: 10 V_ALPHA 32 0 V_COUNTER_R(26) >0<
  V_COUNTER_R SUB 1 TIMES: <-[-
    INCREMENT V_COUNTER <+
    INCREMENT V_ALPHA <<+
  >>>]
  PRINT C_NEWLINE <<<<.
>>>]
\$\endgroup\$
7
\$\begingroup\$

Poetic, 601 bytes

one night i camped a bit
throughout all the forest now
the sweet sights
i saw giant things
i saw little small things
here i am
seated around all my trees i saw
i sleep
i sle-e-p
sleep in a cabin
i am sleep-y
i sleep a bit
i awaken in bed
i stand
i walk
i am ready
i saw a vision of a dragon
i am fooled
i know i am
should i f-ight
i f-light
i did f-light
i did a flight
go away,i do imply
i*m afraid
i run
i leave
i flee
i am timid
i*m just a person,not toughie-tough-guy
no,never
i*m waste
i am stupid
a quitter i was
i am stupid
i*m turning around
i do not appreciate camping
i cry
i am crying
no
no

Poetic is an esolang I created in 2018 for a class project, and it is a brainfuck derivative in which the lengths of words correspond to brainfuck commands (and the +, -, >, and < commands each have 1-digit arguments).

The fact that only word-length dictates the commands means that I technically could have created a program entirely composed of non-words (i.e. the letter X as many times as needed, with spaces in between words), but I wanted to make an interesting free-verse poem out of it while not adding any unnecessary bytes.

If you want to try it online (which is half the point of the class project in the first place), check out my online interpreter!

\$\endgroup\$
4
7
\$\begingroup\$

Jelly, 12 bytes

ØAµ⁶ṁḊ;ṚµƤṚY

Try it online!

ØAµ⁶ṁḊ;ṚµƤṚY  Main Link
ØA            "ABC...XYZ"
         Ƥ    For each prefix,
  µ⁶ṁḊ;Ṛµ     Monadic Link
   ⁶          ' '
    ṁ         (with automatic repetition) molded to the shape of
     Ḋ        All but the first letter of the input (repeat - 1)
      ;       With the input          appended to it
       Ṛ                     reversed
           Y  Join on newlines
          Ṛ   Flip upside down

-3 bytes thanks to miles

\$\endgroup\$
4
  • \$\begingroup\$ 13 bytes \$\endgroup\$
    – Leaky Nun
    Sep 5, 2017 at 20:32
  • \$\begingroup\$ @LeakyNun Oh right cool thanks! \$\endgroup\$
    – hyper-neutrino
    Sep 5, 2017 at 20:33
  • \$\begingroup\$ Yay, another use for the prefix quick. 12 bytes since mold will reshape here using the length implicitly. \$\endgroup\$
    – miles
    Sep 5, 2017 at 20:37
  • \$\begingroup\$ @LeakyNun Actually, unfortunately that would make it invalid because there cannot be extra spaces (it would take 2 bytes to fix) \$\endgroup\$
    – hyper-neutrino
    Sep 5, 2017 at 20:37
6
\$\begingroup\$

Octave, 53 49 46 45 bytes

1 byte removed thanks to @Sanchises

for k=25:-1:0,disp([blanks(k) 65+k:-1:65])end

Try it online!

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

05AB1E, 10 bytes

žpDvÐg<ú,¦

Try it online!

Explanations:

žpDvÐg<ú,¦
žp           Push the uppercased alphabet, reversed
  D          Duplicate
   v         For each letter (we just want to loop 26 times, so we use the 
                already pushed alphabet for that purpose)
    Ð        Triplicate
     g<      Length of the string - 1
       ú     Add that number of spaces at the beginning of the string
        ,    Print with newline
         ¦   Remove the 1st element of the remaining copy of the string
\$\endgroup\$
5
\$\begingroup\$

Perl 6, 37 bytes

Saved 9 bytes thanks to @Massa.

say " "x$_,chrs $_+65...65 for 25...0

Try it online!

Explanation: 25...0 is a range from 25 to 0 (as expected). We iterate over that range, saying (= printing with newline) that many spaces and the string of characters that have ASCII codes (chrs) from 65 + that number ($_+65...65).

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 25...0 is the shorter way :-) \$\endgroup\$
    – Massa
    Sep 6, 2017 at 14:38
  • \$\begingroup\$ try say " "x$_,chrs $_+65...65 for 25...0 :-) \$\endgroup\$
    – Massa
    Sep 6, 2017 at 14:41
  • \$\begingroup\$ Many thanks! I never knew about that! And the sub form is better too (too bad I made this one from the top of my head). (This is why I like to use Perl 6 for codegolf, I always discover something new.) \$\endgroup\$
    – Ramillies
    Sep 6, 2017 at 18:28
5
\$\begingroup\$

Vim, 43 keystrokes

:h<_<CR>jjYZZPVgUxjpqqy$-i <Esc>lpl"aDYPD"ap+q25@q

You can see it in action in this GIF made using Lynn's python script

enter image description here

\$\endgroup\$
4
\$\begingroup\$

Charcoal, 19 11 bytes

-8 bytes thanks to ASCII-only.

F²⁶«P⮌…α⊕ι↗

Try it online! Link is to verbose version.

\$\endgroup\$
14
  • \$\begingroup\$ This maybe? tio.run/##S85ILErOT8z5/… \$\endgroup\$
    – ASCII-only
    Sep 5, 2017 at 21:10
  • \$\begingroup\$ Wait noooooo there's leading space \$\endgroup\$
    – ASCII-only
    Sep 5, 2017 at 21:11
  • \$\begingroup\$ Son of a... I need to look through every single command and operator Charcoal has. >_> Thanks! \$\endgroup\$ Sep 5, 2017 at 21:11
  • \$\begingroup\$ Fixed tio.run/… \$\endgroup\$
    – ASCII-only
    Sep 5, 2017 at 21:12
  • 1
    \$\begingroup\$ @ASCII-only CycleChop...but you forgot Increment (or whatever it's called) \$\endgroup\$ Sep 6, 2017 at 9:00
4
\$\begingroup\$

Ruby, 54 52 bytes

25.downto 0{|n|puts' '*n+[*?A..?Z][0..n].reverse*''}

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Cubix, 43 46 bytes

$/\;u:\s/':(!$u;:'@^!@Wu;oSU;o+<u(;;oN;(!|

Try it online!

Cubified

      $ / \
      ; u :
      \ s /
'  : ( ! $ u ; : ' @ ^
! @ W u ; o S U ; o + <
u ( ; ; o N ; ( ! | . .
      . . .
      . . .
      . . .

Watch it run

Have managed to shave a few more of this, but it was a bit more difficult than I thought. There is a substitute character after the first quote to give me 26.

  • '<sub> push 26 onto the stack as the base number
  • :(! duplicate base as a counter, decrement, test for truthy
  • u on true skip the $ command and u-turn to the right
    • So;u push 32, output as character, pop 32 and u-turn right onto the decrement
  • $ on false jump the next u command
  • ;:'@^ pop, duplicate the base number, push 64 onto stack and redirect into a torturous route
  • $\s/:\/u;$ this is the order of the steps on the top face. It boils down to swap the counter with the 64. Ends with a skip over the redirect that put it here.
  • <+o;U redirect to add, output character, pop, u-turn left
  • (! decrement, test for truthy. If true starts on a path which hits the u-turn and goes back to the redirect.
  • |(;No on false, reflect, redundant test, redundant decrement, pop, push 10 and output character
  • ;;(u!@W pop down to the base number, decrement, u-turn right onto truthy test, halt if false otherwise change lane onto the duplicate at the beginning. Rinse and repeat.
\$\endgroup\$
4
\$\begingroup\$

Python, 83 bytes

[print(' '*i+''.join([chr(64+i)for i in range(i+1,0,-1)]))for i in range(25,-1,-1)]

My first answer on codegolf :)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ A belated welcome to PPCG! nice answer! \$\endgroup\$ Sep 8, 2017 at 22:36
4
\$\begingroup\$

sed 4.2.2 + Bash, 50 bytes

s/^/printf %25s;printf %s {Z..A}/e
:
p
s/ \S//
t
d

Try it online!


Bash + sed 4.2.2, 51 bytes

printf %s {Z..A}|sed 'h
s/./ /g
G
:
s/ [^ ]//p
t
d'

Building on @DigitalTrauma's answer.

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Perl 5 + -p, 37 bytes

}{$\=$"x$-++.($a=$_.$a).$/.$\for A..Z

Explanation

Since -p is being used with no input, the leading }{ is to break out of the implicit while(<STDIN>){ that's added. This builds the string, in reverse, into $\ which is implicitly output after any content that is printed. for each char in A..Z, $\ is set to $- (which starts as 0 and is post-incremented for the next loop) $"s (which is the record separator and is initialised to space) to indent the string, concatenated with $a (which is prepended with $_, the current letter from the for loop), followed by $/ (the line terminator, defaults to "\n") and the existing contents of $\.

Try it online!


Perl 5 + -M5.10.0, 37 bytes

$#@-=say$"x$#@,reverse@@for\(@@=A..Z)

Explanation

This approach outputs the string in order directly. for each char in the reference (\(...)) to @@ (which is set to A..Z), this runs the loop once for each letter, @@'s final index is decremented by the result of outputting (say, includes a final newline) $" (space) 'the final index of @@ times', followed by the reverse of @@. Using the return from say as the decrement means that the output happens before the final index is removed avoiding the need to add another entry to the list. So in the first iteration this outputs 25 spaces and Z to A, then 24 spaces and Y to A ... then 1 space and BA and 0 spaces and A.

I feel like it should be possible to remove some syntax here. I played around with a way to define a list that shrinks but doesn't stop the loop halfway through and the \(...) seems to do just that, whereas [...] is seen as one list entry instead. Also trying to find a non-word character that works with the $#_ notation was trickier than I'd hoped, @; - my usual go-to results in evaluation of $# (which is removed).

Try it online!

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

JavaScript, 75 74 bytes

1 byte saved thanks to Rick Hitchcock

f=(a=65,b='',c)=>a>90?'':f(a+1,b+' ',c=String.fromCharCode(a)+[c])+`
`+b+c

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Save a byte by initializing b (b=''), then taking b out of the square brackets. \$\endgroup\$ Sep 5, 2017 at 22:21
  • \$\begingroup\$ @RickHitchcock. Thanks. \$\endgroup\$
    – user72349
    Sep 5, 2017 at 22:27
3
\$\begingroup\$

Perl 5, 49 bytes

$_=$"x26 .join'',reverse A..Z,Z;say while s/ \S//

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Looks like you're missing the first A, but seems that can be fixed by changing $"x25 to $"x26! \$\endgroup\$ Sep 6, 2017 at 8:58
  • \$\begingroup\$ When I added the extra Z, I forgot to account for that. \$\endgroup\$
    – Xcali
    Sep 6, 2017 at 13:06
3
\$\begingroup\$

Pyke, 8 bytes

G_.<XFo}h-

Try it here!

           -  o = 0
G_         -    reversed(alphabet)
  .<       -   suffixes(^)
    XF     -  for i in ^:
      o    -      o++
       }   -     ^ * 2
        h  -    ^ + 1
         - -   i.lpad(" ", ^)
           - for i in reversed(^):
           -  print i

I can see the right language doing this in 6 bytes if they had a builtin for prepend n spaces to string as well as what Pyke does

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

PHP (63 58 55 bytes)

This is possibly my favorite strange corner of PHP, a corner which it inherits from Perl:

for($c=A;$c!=AA;$q="$s$z 
$q",$s.=" ")$z=$c++.$z;echo$q;

This outputs the trailing newline, as explicitly permitted. This can be run in php -r to save the opening <?php needed to put this in a file.

Explanation: when a variable containing the string 'A' is incremented in PHP, it becomes 'B' and then 'C' and so on up until 'Z' becomes 'AA'. There is no digit before 'A' to start with in this madcap algebra, and the decrement operator does not undo it, so we save the incrementally reversed alphabet to $z (which defaults to NULL which when it gets concatenated with a string behaves like the empty string -- the same happens with $s and $q). Whitespace is accumulated in $s and the whole string is accumulated backwards in variable $q which means we have to echo it at the end.

Thanks to Titus for golfing off my curly braces and telling me that I don't need to take a penalty for inline-evaluation flags like -r.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ That´s 57 bytes, if you use a linux linebreak. -r is free. Two bytes shorter: for($c=A;$c!=AA;$q="$s$z\n$q",$s.=" ")$z=$c++.$z;echo$q; \$\endgroup\$
    – Titus
    Sep 8, 2017 at 18:32
  • \$\begingroup\$ @Titus thanks, gave you a kudos in the answer. \$\endgroup\$
    – CR Drost
    Sep 8, 2017 at 20:08
  • \$\begingroup\$ nm. Just note that -R and -F are not free. See codegolf.meta.stackexchange.com/questions/2424/… \$\endgroup\$
    – Titus
    Sep 9, 2017 at 9:04
  • \$\begingroup\$ I believe you can save a byte if you use $c<AA. \$\endgroup\$ Sep 20, 2017 at 19:25
  • 1
    \$\begingroup\$ @IsmaelMiguel sorry, I was too terse. I was thinking when I wrote that, "maybe there is a way to shuffle things around without gaining bytes so that the A case happens first and then we can detect AA vs. B but I do not think that I am smart enough to see it." I didn't mean to be flippant and I will try to watch out for that in the future. \$\endgroup\$
    – CR Drost
    Sep 20, 2017 at 19:44
3
\$\begingroup\$

SOGL V0.12, 10 8 bytes

Z±{Xf}⁰¼

Try it Here!

\$\endgroup\$
2
  • \$\begingroup\$ Just curious, how long is the compressed version? \$\endgroup\$ Sep 5, 2017 at 21:01
  • \$\begingroup\$ @cairdcoinheringaahing TL;DR way too long. SOGLs compression sucks at (and is specifically made not for) repetitive stuff. It'd be very hard to tell as the compression isn't automated (automation would make it take 701 choose x attempts for any integer x) but a rough attempt was 450 bytes :P \$\endgroup\$
    – dzaima
    Sep 5, 2017 at 21:12
3
\$\begingroup\$

Common Lisp, 84 82 bytes

(dotimes(i 26)(format t"~v@{ ~}~a
"(- 25 i)(subseq"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))

Try it online!

Two bytes less thanks to @Ascii-only!

\$\endgroup\$
1
  • \$\begingroup\$ 82 \$\endgroup\$
    – ASCII-only
    Apr 26, 2018 at 5:52
3
\$\begingroup\$

Python 3, 71 69 bytes

for i in range(26):print(' '*(25-i)+'ZYXWVUTSRQPONMLKJIHGFEDCBA'[i:])

Try it online!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Welcome to the site! This question does already have multiple Python answers (don't worry, we don't discourage duplicate answers), but still, be sure to check out our tips for golfing in Python page, to see if you can shave anymore bytes off. Also, feel free to browse our active challenges to see if anything catches your eye. Hope you enjoy it here! \$\endgroup\$ Sep 30, 2020 at 22:34
  • 1
    \$\begingroup\$ @cairdcoinheringaahing Thanks for the warm welcome! Thanks to you I decided to take the time to try and golf my code a bit more. Although it took me almost 2 hours to find the obvious save, I had a lot of fun. \$\endgroup\$
    – mehbark
    Oct 1, 2020 at 1:56

Your Answer

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

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