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

98 Answers 98

18
\$\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\$
  • 2
    \$\begingroup\$ @MDXF IMO, that's a really dumb rule \$\endgroup\$ – DJMcMayhem Sep 5 '17 at 20:20
  • 3
    \$\begingroup\$ Hmm... I guess I'll remove the rule, then. status-completed \$\endgroup\$ – MD XF Sep 5 '17 at 20:22
  • 2
    \$\begingroup\$ I might propose a PR documenting that feature when I find the time. Seems to be a good way to learn a bit of python from a well-written, easy-to-read code \$\endgroup\$ – scottinet Sep 6 '17 at 8:39
  • 6
    \$\begingroup\$ Why does žp exist when Au is golden? BADUM tissss \$\endgroup\$ – Magic Octopus Urn Sep 6 '17 at 17:44
  • 5
    \$\begingroup\$ Using 05AB1E, create a file documenting all of it's features, shortes code wins :P \$\endgroup\$ – Christian Sep 8 '17 at 8:30
21
\$\begingroup\$

R, 67 55 bytes

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

Try it online!

\$\endgroup\$
  • 4
    \$\begingroup\$ R is beating Python on a string challenge? Nice. +1 for LETTERS \$\endgroup\$ – CriminallyVulgar Sep 6 '17 at 10:00
  • 1
    \$\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 '17 at 20:13
  • \$\begingroup\$ -2 bytes if you change sep to s. Functions will autocomplete named arguments if there aren't collisions \$\endgroup\$ – Punintended Mar 30 '18 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 '18 at 17:30
17
\$\begingroup\$

Python 2, 57 bytes

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

Try it online!

\$\endgroup\$
15
\$\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
    \$\begingroup\$ I do these on my phone too, +1 \$\endgroup\$ – Stan Strum Sep 5 '17 at 22:45
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\$
  • \$\begingroup\$ You can save two bytes by changing :x to : and tx to t. \$\endgroup\$ – Jordan Oct 30 '17 at 1:02
11
\$\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\$
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\$
  • \$\begingroup\$ Same lengths as the C# and brainfuck answers :D \$\endgroup\$ – Conor O'Brien Sep 7 '17 at 0:30
8
\$\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\$
  • \$\begingroup\$ Why doesn't f['Z'..'A'] work? \$\endgroup\$ – Conor O'Brien Sep 6 '17 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 '17 at 16:09
  • \$\begingroup\$ Ah, I see now. Thanks! \$\endgroup\$ – Conor O'Brien Sep 6 '17 at 18:19
8
\$\begingroup\$

Python 2, 66 64

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

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to Programming Puzzles & Code Golf - nice first answer! \$\endgroup\$ – MD XF Sep 5 '17 at 20:43
  • 2
    \$\begingroup\$ Thanks! Figured I'd give it a try instead of just lurking. \$\endgroup\$ – Artemis_134 Sep 5 '17 at 20:45
  • 2
    \$\begingroup\$ You can remove the space between print and ' for 65 bytes. \$\endgroup\$ – Mr. Xcoder Sep 5 '17 at 20:48
  • \$\begingroup\$ I ported your answer into Pyth, take a look: codegolf.stackexchange.com/a/141939/63757 \$\endgroup\$ – Stan Strum Sep 7 '17 at 2:40
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\$
6
\$\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\$
  • \$\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 '17 at 21:16
  • \$\begingroup\$ @ThePirateBay No problem! \$\endgroup\$ – Arnauld Sep 5 '17 at 21:17
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\$
  • \$\begingroup\$ @Sanchises Thanks! \$\endgroup\$ – Luis Mendo Sep 7 '17 at 11:21
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\$

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

-3 bytes thanks to miles

\$\endgroup\$
  • \$\begingroup\$ 13 bytes \$\endgroup\$ – Leaky Nun Sep 5 '17 at 20:32
  • \$\begingroup\$ @LeakyNun Oh right cool thanks! \$\endgroup\$ – HyperNeutrino Sep 5 '17 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 '17 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\$ – HyperNeutrino Sep 5 '17 at 20:37
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\$
  • 1
    \$\begingroup\$ 25...0 is the shorter way :-) \$\endgroup\$ – Massa Sep 6 '17 at 14:38
  • \$\begingroup\$ try say " "x$_,chrs $_+65...65 for 25...0 :-) \$\endgroup\$ – Massa Sep 6 '17 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 '17 at 18:28
4
\$\begingroup\$

Charcoal, 19 11 bytes

-8 bytes thanks to ASCII-only.

F²⁶«P⮌…α⊕ι↗

Try it online! Link is to verbose version.

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

Perl 5, 36 bytes

35 bytes code + 1 for -p.

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

Note: TIO doesn't support empty input, so a newline is provided, this results in an extraneous newline, but when running at command-line with empty input, this is not displayed.

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
    \$\begingroup\$ A belated welcome to PPCG! nice answer! \$\endgroup\$ – Conor O'Brien Sep 8 '17 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\$

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\$
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\$
  • \$\begingroup\$ Save a byte by initializing b (b=''), then taking b out of the square brackets. \$\endgroup\$ – Rick Hitchcock Sep 5 '17 at 22:21
  • \$\begingroup\$ @RickHitchcock. Thanks. \$\endgroup\$ – user72349 Sep 5 '17 at 22:27
3
\$\begingroup\$

Perl 5, 49 bytes

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

Try it online!

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

Ruby, 54 52 bytes

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

Try it online!

\$\endgroup\$
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\$
  • 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 '17 at 18:32
  • \$\begingroup\$ @Titus thanks, gave you a kudos in the answer. \$\endgroup\$ – CR Drost Sep 8 '17 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 '17 at 9:04
  • \$\begingroup\$ I believe you can save a byte if you use $c<AA. \$\endgroup\$ – Ismael Miguel Sep 20 '17 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 '17 at 19:44
3
\$\begingroup\$

SOGL V0.12, 10 8 bytes

Z±{Xf}⁰¼

Try it Here!

\$\endgroup\$
  • \$\begingroup\$ Just curious, how long is the compressed version? \$\endgroup\$ – caird coinheringaahing Sep 5 '17 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 '17 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\$
  • \$\begingroup\$ 82 \$\endgroup\$ – ASCII-only Apr 26 '18 at 5:52
2
\$\begingroup\$

Python 2, 72 67 bytes

i=26
while-~i:print' '*i+''.join(map(chr,range(65,91)))[i::-1];i-=1

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Bubblegum, 85 bytes

Hexdump:

0000000: 53c0 05a2 2223 c2c3 4243 8283 0203 fcfd  S..."#..BC......
0000010: 7c7d bcbd 3c3d dcdd 5c5d 9c9d 1cb9 7069  |}..<=..\]....pi
0000020: 2159 0789 ea49 524d 825a a255 12a9 8e28  !Y...IRM.Z.U...(
0000030: 5544 a821 a882 803c 5e59 3c72 3865 7088  UD.!...<^Y<r8ep.
0000040: 6315 c522 8621 82c6 47e1 21b1 e12c 280d  c..".!..G.!..,(.
0000050: 2681 d811 00                             &....

Try it online!

\$\endgroup\$
  • \$\begingroup\$ A reason behind the downvote, perhaps? \$\endgroup\$ – totallyhuman Sep 5 '17 at 20:44
  • \$\begingroup\$ Maybe because the language is really a glorified text compressor? I haven't downvoted fwiw \$\endgroup\$ – Conor O'Brien Sep 6 '17 at 10:48

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.