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

  • 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!


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>

  • 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

102 Answers 102


Swift, 118 bytes

var s="";for i in 0..<26{for _ in 0..<25-i{s+=" "};for j in 0..<26-i{s+="\(UnicodeScalar(90-i-j)!)"};s+="\n"};print(s)


var s = ""

for i in 0 ..< 26 {
    for _ in 0 ..< 25 - i {
        s += " "

    for j in 0 ..< 26 - i {
        s += "\(UnicodeScalar(90 - i - j)!)"

    s += "\n"


Try it online!


Stax, 13 9 bytes


Run and debug it at staxlang.xyz!

Unpacked (15 bytes) and explanation

VAr                Uppercase alphabet, reversed
   |]              List of suffixes
     m             Map rest of program over array, printing each element with a linefeed:
      c              Copy top of stack
       %             Length
        Hv           Double and decrement
          )          Pad string on left with spaces to the specified length

I think that VAr|]mc%Hv|z SHOULD work for 10 bytes (once packed), but what looks to me like a bug kills that solution. I stupidly confused |z with ) there. Thanks @recursive for pointing that out (and saving even another byte)!


T-SQL, 115 bytes

SET @=STUFF(@,len(@)/2,2,'')IF len(@)>0GOTO a

Shorter to just hard-code the initial string, then I used STUFF() to snip out two characters from the middle each loop.

I can save 3 bytes by using a CHAR(51) instead of a VARCHAR(51), but that prints full-width trailing spaces for all rows, which don't appear to be allowed.


C# (.NET Core), 133 114 bytes

var S="";for(int I=26;I-->0;){var C='@';for(;C++<I+64;)S+=" ";for(;C>'@';)S+=C--;S+="\n";}System.Console.Write(S);

Try it online!

var S="";                   // Initialize the return string
for(int I=26;I-->0;){       // For all 26 rows (with I as the space count)
    var C='@';              // Initializing C with the char '@' which is one under 'A'
    for(;C++<I+64;)         // For all spaces needed and sets the char one up ('@' -> 'A', 'A' -> 'B')
        S+=" ";             // Add a space to the string
    for(;C>'@';)            // For all characters which are needed from the char countet above up down to 'A'
        S+=C;               // Add the char to the string
    S+="\n";                // Add a new line to the string
System.Console.Write(S);    // Output the string

Japt -R, 15 12 bytes

;Bå+ ËÔiEçÃÔ

Test it

;B               :Uppercase alphabet
  å+             :Cumulatively reduce by concatenation giving the prefixes
     Ë           :Map each string at 0-based index E
      Ô          :  Reverse
       i         :  Prepend
        Eç       :   Space repeated E times
          Ã      :End map
           Ô     :Reverse
                 :Implicitly join with newlines and output

K4, 22 bytes


,/'(1_')\0 25_|51$.Q.A


Generate two lists and reduce each until they are empty.

,/'(1_')\0 25_|51$.Q.A / the solution
                  .Q.A / A..Z
               51$     / pad to 51 chars
              |        / reverse it
         0 25_         / cut (_) at indices 0 and 25
   (   )\              / perform this along
    1_'                / drop (_) first from each (') list
,/'                    / flatten (,/) each (')


Another 22 byte solution:


><>, 51 49 bytes


Try it online!


Dyalog APL, 34 23 21 bytesSBCS


Try it online!

Thanks to Adám for the help!


                  ⍳26 ⍝ 1..26
                 ⌽    ⍝ Reverse, 26..1
 {             }¨     ⍝ For each in this range. Iteration: ⍵
            ↑         ⍝ Take...
           ⍵          ⍝ ...⍵ elements...
             ⎕A       ⍝ ...from the alphabet
          ⌽           ⍝ Reverse
         ↑            ⍝ Pad with spaces...
  (1-2×⍵)             ⍝ ...(1 - 2*current iteration) elements
↑                     ⍝ Format
  • \$\begingroup\$ You have a stray . \$\endgroup\$ – Adám Sep 7 '17 at 12:18
  • \$\begingroup\$ Also, I'd write instead of . \$\endgroup\$ – Adám Sep 7 '17 at 12:19
  • \$\begingroup\$ Save two bytes: ↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26 \$\endgroup\$ – Adám Sep 7 '17 at 12:25
  • \$\begingroup\$ That's clever :). Ty. \$\endgroup\$ – Ven Sep 7 '17 at 12:32

Gaia, 14 bytes


Try it online!


Ruby, 58 bytes

Not the best answer for Ruby, but still good enough to get second place out of three entries lol. I just wanted to try a regex-based solution.

s=' '*26+[*?A..?[].reverse*''
puts s while s.sub!(/ \S/){}

Try it online!


Whitespace, 163 bytes

Try it online!

                                    (s = space, t = tab, l = linefeed)
sssttstsl   push 26                 For x = 26 times

lssl        start: ""
sls         dup (Stack: [26, 26])       For y = x times

lsssl       spaces:
ssstl       push 1
tsst        sub                             decrement space counter
sls         dup
ltstl       jz end_spaces                   if space counter > 0
ssstsssssl  push 32
tlss        outchar                             print space
lslsl       jmp spaces
lsstl       end_spaces:                 next y

sll         drop                        drop y
sls         dup (Stack: [26, 26])

lssssl      letters:
sls         dup                         for y = x to 0
ssstssssssl push "@"
tsss        add (Stack: [26, 26, "Z"])      add y to "@" to get start letter
tlss        outchar                         print that letter
ssstl       push 1
tsst        sub                             decrement y
sls         dup
ltsstl      jz end_letters
lslssl      jmp letters                 next y
lssstl      end_letters:

sll         drop                        drop y
ssstl       push 1
tsst        sub                         decrement x
sls         dup
ltsttl      jz end
ssststsl    push 10
tlss        outchar                     print newline
lsll        jmp start               next x

Forth (gforth), 54 bytes

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

Try it online!

How it works

: f ( n -- ) \ Print n+1 lines of searchlight.
  for        \ loop from n to 0 inclusive [i]
    i spaces   \ print i spaces
    i for      \ loop from i to 0 inclusive [j];
               \ in Forth, the innermost loop count is always i
      i 65 + emit \ print a char whose charcode is j + 65
    next       \ end inner loop
    cr         \ print a newline
  next ;     \ end outer loop
25 f       \ push 25 and call f

Just started fiddling with Forth. Unlike the golfing tip says, it looks like n for .. next loop is the shortest for simple decreasing loops and n1 n0 do .. loop for increasing loops. The recursive call word recurse or recursive is way too verbose, and it still costs at least an if .. then.


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.