69
\$\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\$
  • 4
    \$\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

1
\$\begingroup\$

Perl 6, 57 bytes

.put for (' 'Xx(25...0))Z~(('Z'...'A') »...»'A')».join

Try it online!

Expanded:

  .put              # print with trailing newline

for                 # for each of the following

  (
      ' ' 

    Xx              # cross using string repetition operator

      ( 25 ... 0 )  # from 25 down to 0
  )

  Z~                # zip using string concatenation

  (
    ( 'Z' ... 'A' ) # descending sequence of starting values
    »...»           # combine those into sequences each with an end value of 'A'
    'A'
  )».join           # combine each of the sub sequences into strings
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Clojure v1.8, 93 bytes

Converted Renzo's answer to Clojure.

(dotimes[i 26](prn(apply str(concat(repeat(- 25 i)" ")(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))))

Explanation

(dotimes [i 26] ...)                 We will print 26 lines, i is between[0, 26)
(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)  Take the string starting from position 'i'
(repeat(- 25 i)" ")                  Repeat the whitespaces, we start from 25 because the last line doesn't have whitespaces
(prn(apply str(concat(repeat(- 25 i)" ")(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))) Concatenate the sequence of whitespaces and the string in order to have the desired effect with 'str' next

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

brainfuck, 119 bytes

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

Try it online!

Could be golfable by better initializing the tape - there is a modulo solution that would pop 90,32,26 and 10, that would also probably leave the tape a little less fragmented.

Also could combine all three loops unto one, by juggling the index as the difference from the ASCII code 'Z', or something.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Javascript, 82 bytes

for(i=26;i;){console.log(" ".repeat(i-1)+"ZYXVUTSRQPONMLKJIHGFEDCBA".slice(-i--))}

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Twig, 93 bytes

Twig is a template language developed to be used in PHP, which is similar to Smarty, Django or Jinja.

{%for a in "Z".."A"%}{{("%"~(26-loop.index)~"s%s")|format(f,range(a,"A")|join())}}
{%endfor%}

This code relies in the fact that the environment option strict_variables defaults to false. Otherwise, it will break.

Try it on https://twigfiddle.com/9umogr (check the raw result).
If you want to copy-paste the code, make sure that you disable strict_variables, since the website sets that to true.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Bash + coreutils, 64 bytes

printf '%s' {Z..A}|sed 'h;s/./ /g;G;s/ \n//;p;:a;s/ \b.//p;ta;Q'
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I like this, but it seems to be missing the newline at the end. \$\endgroup\$ – Robert Benson Sep 8 '17 at 1:36
  • \$\begingroup\$ I guess the requirements were a bit unclear. \$\endgroup\$ – Robert Benson Sep 8 '17 at 2:04
1
\$\begingroup\$

C, 82 characters

char*a="ZYXWVUTSRQPONMLKJIHGFEDCBA\n",i=54;main(){while(i)printf("%*s",i-=2,a++);}

Works for any character coding, by embedding the full alphabet. We print subsequent trailing substrings in a field twice as wide as required, to get the leading spaces.

I had hoped to be able to reduce it further with while(printf());, but couldn't arrange for the return value to reach zero at the right point.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Retina, 38 bytes


25$* Z
{-2=`
$'
}T`L`_L`.$
;{:G`
 \w

Try it online!

Explanation


25$* Z

Initialise the working string to 25 spaces and a single Z.

{-2=`
$'
}T`L`_L`.$

The usual approach for generating the alphabet: repeatedly duplicate the last letter, then decrement that letter with a transliteration, removing As instead of decrementing them further. That means once we get to A, the second stage will delete the letter which was added by the first stage, so there won't be any net change and the loop stops. That gives us the first line of the output.

;{:G`
 \w

Now we really just repeatedly print the current line and the drop a space followed by a letter. The construction is slightly weird due to how loops and printing works in Retina. We need to print before we drop the letter, which requires a separate stage that otherwise doesn't do anything, and we also need to disable the implicit printing at the end of the program.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Husk, 15 bytes

mṠ+ȯR' ←Lhṫ…"ZA

Try it online!

-5 thanks to Zgarb. Still a newb :p

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pyth, 14 bytes

-2 from dave and ven thanks guys

V_UG+*dNrG1=PG

Explanation coming when I figure it out wake up.

Pyth, 16 bytes

V26p*-25Nd>_rG1N

Explanation:

V26        26 times, could've written lG, but it's the same
   p*-25Nd Print without newline: 25-index spaces (could've used + instead of p but it's simpler to explain)
   >_rG1N  Implicit print with newline: The last index characters of the reverse uppercase alphabet

Try it online!

While you're here, here's Artemis's first answer ported into Pyth:

Pyth, 21 20 bytes (non-competing)

J26W=tJ+*dJ>_rG1-25J

An explanation for Artemis's answer:

J26        Set J to 26
W          While...
 =tJ       Decrement J (J-=1)
 +*dJ      J spaces plus...
 >_rG1-25J The last 25-index characters of the reverse uppercase alphabet

I should stop writing these on my phone

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Similar to this answer, but > doesn't seem like the way to go. How about setting G to tG, as in V_UG+*dNrG1=tG for 14 bytes? \$\endgroup\$ – Dave Sep 7 '17 at 3:13
  • \$\begingroup\$ @Dave similar to what answer? \$\endgroup\$ – Stan Strum Sep 7 '17 at 3:16
  • \$\begingroup\$ Yours! This being parent lol \$\endgroup\$ – Dave Sep 7 '17 at 3:16
  • \$\begingroup\$ @Dave I knew I was doing something wrong \$\endgroup\$ – Stan Strum Sep 7 '17 at 3:17
  • \$\begingroup\$ It's too early for this \$\endgroup\$ – Stan Strum Sep 7 '17 at 15:11
1
\$\begingroup\$

AWK, 76 bytes

{for(;++j<27;)printf"%"53-2*j"s\n",substr("ZYXWVUTSRQPONMLKJIHGFEDCBA",++z)}

Try it online!

Tried 3-4 different versions, including double for loop, this is the fewest bytes I could come up with.

Not sure if I should add 1 byte since it does require some input to produce output.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Java, 206 bytes

public class Main{public static void main(String[]args){int i,j,k,l=90;for(k=26;k>=0;k--){for(i=k-1;i>0;i--){System.out.print(" ");}for(j=l;j>=65;j--){System.out.print((char)j);}l--;System.out.println();}}}

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I'm new so not familiar how to add a post, hope to help someone.!! :D \$\endgroup\$ – david paavada Sep 8 '17 at 10:40
  • 1
    \$\begingroup\$ Also, the bytecount must be visible on the header. \$\endgroup\$ – Erik the Outgolfer Sep 8 '17 at 11:06
  • \$\begingroup\$ its actually shorter to define an interface than class. also, the args array doesn't have to be called args, can be let's say a as well. \$\endgroup\$ – peech Sep 8 '17 at 15:48
  • \$\begingroup\$ You can use public class M to save three bytes. And String[]a to save three more. \$\endgroup\$ – MD XF Sep 8 '17 at 16:16
1
\$\begingroup\$

Java, 196 134 bytes

Yes, this has no chance of winning overall, but it helps to re-familiarize myself with the language. Any improvements are welcome, but know I have not yet had time to read the Tips or Golfing in Java.

public class A{public static void main(String[]a){for(int i=0;i<26;i++){for(int j=0;j<25-i;j++)System.out.print(" ");for(char c=(char)(90-i);c>=65;c--)System.out.print(c);System.out.println();}}}

Thanks to JollyJoker for suggesting improvements. I won't get a chance to investigate lambdas for this one, but I'll remember it for the future. This is as short as I'll make this one. Eclipse kept complaining when I changed all ints to chars, so I'll look into that some more.

String a(){String r="";for(int i=0;i<26;i++){for(int j=0;j<25-i;j++)r+=" ";for(char c=(char)('Z'-i);c>=65;c--)r+=c;r+="\n";}return r;}

Try it online!

Ungolfed:

public class A { public static void main(String[] args) { for (int i = 0; i < 26; i++) { for (int j = 0; j < 25 - i; j++) System.out.print(" "); for (char c = (char)(90 - i); c> = 65; c--) System.out.print(c); System.out.println(); } } }

String a() {
    String r = "";
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 25 - i; j++)
            r += " ";
        for (char c = (char)('Z'-i); c >= 65; c--)
            r += c; r+= "\n";
    }
    return r;
}
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You can give the answer as a method returning a String instead of a full program. Use Java 8 lambdas for the method. Combine nested for loops if you can find a way. The char 32 is space and 10 is newline; concatenate chars like ""+=c to build a String. \$\endgroup\$ – JollyJoker Sep 7 '17 at 11:59
  • \$\begingroup\$ You can use n-> instead of ()-> even if there's no input. Using it to store a char inside the code might be ok. \$\endgroup\$ – JollyJoker Sep 7 '17 at 12:34
  • \$\begingroup\$ Thanks for the tips! I'll edit my answer in a few hours with your improvements. \$\endgroup\$ – Jimmy Johnson Sep 7 '17 at 12:46
  • \$\begingroup\$ You can copy / paste some lambda boilerplate from here \$\endgroup\$ – JollyJoker Sep 7 '17 at 12:51
  • \$\begingroup\$ Avoid cast by using 'Z' instead of 90 and changing everything from int to char \$\endgroup\$ – JollyJoker Sep 7 '17 at 13:14
1
\$\begingroup\$

VBA, 65 Bytes

Anonymous VBE immediate window function that takes no input and outputs to the VBE immediate window

For i=0To 25:?Spc(25-i);:For j=0To 25-i:?Chr(90-j-i);:Next:?:Next

Naïve Version, 68 Bytes

For i=0To 25:?Spc(25-i)Right("ZYXWVUTSRQPONMLKJIHGFEDCBA",26-i):Next
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Python 2, 86 83 bytes

for x in range(25,-1,-1):print(" "*x)+"".join([chr(y+65)for y in range(x+1)][::-1])

Thanks to Stephen for the 3 extra bytes.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ 3? less bytes by removing extra spaces: for x in range(25,-1,-1):print(" "*x)+"".join([chr(y+65)for y in range(x+1)][::-1]) \$\endgroup\$ – Stephen Sep 6 '17 at 23:11
1
\$\begingroup\$

q/kdb+, 32 31 bytes

Solution:

raze@/:(1_')\[(25#" ";(|).Q.A)]

Example:

q)raze@/:(1_')\[(25#" ";(|).Q.A)]
"                         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"
""

Explanation:

Create two lists, 1 with 25 spaces, 1 with the reversed alphabet, then drop the first item from each list and join together. Use converge \ to terminate when the output matches previous output (hence this results in a trailing empty line):

raze each (1_')\[(25#" ";reverse .Q.A)] / ungolfed solution
                 (      ;            )  / two item list
                  25#" "                / 25 take " ", whitespace 25 long
                         reverse .Q.A   / .Q.A is uppercase alphabet A..Z, reverse reverses, so Z..A
          (   )\[                     ] / converge running left function with right arguments
           1_'                          / 1 drop (_) each (') removes first item from each sublist and returns result (2 lists)
raze each                               / raze reduces a list of lists, so we reduce each sublist of 2 lists to a single list
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Acc!!, 113 bytes

26
Count i while i-_ {
	Count b while b-25+i {
		Write 32
	}
	Count t while t-_+i {
		Write 90-t-i
	}
	Write 10
}

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Implicit, 24 23 22 19 bytes

À¦\^(-(1ß-);%\1^ß1ö
À                    « push alphabet                       »;
 ¦                   « swap case                           »;
  \                  « reverse                             »;
   ^                 « push length                         »;
    (                « do                                  »;
     -               «  decrement string length            »;
      (1..)          «  while top of stack truthy          »;
        ß            «   print space                       »;
         -           «   decrement string length           »;
           ;         «  pop string length                  »;
            %        «  print string                       »;
             \1      «  knock first character off string   »;
               ^     «  push length                        »;
                ß1   «  print newline                      »;
                  ö  «  exit without implicit output if top of stack falsy  »;
                     « implicit infinite loop              »;

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 87 71 bytes

Submission

{(0..25).map{(it..25).map{print(" ")
it}.map{print('Z'-it)}
println()}}

Beautified

        {
            // For it from 25 to 0
            (0..25).map {
                // Print that number of spaces
                // Print the alphabet backwards from that letter
                (it..25).map { print(" ")
                it}.map { print('Z' - it) }
                // Newline
                println()
            }
        }

Test

var f:()->Unit =
{(0..25).map{(it..25).map{print(" ")
it}.map{print('Z'-it)}
println()}}
fun main(args: Array<String>) {
    f()
}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

uBASIC, 74 bytes

That pesky Chr$ function sure does like to add extra spaces

0ForI=0To25:?Tab(25-I);:ForJ=0To25-I:?Left$(Chr$(90-I-J),1);:NextJ:?:NextI

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

MY-BASIC, 100 bytes

Anonymous function that takes no input and outputs to the console

For I=0 To 25
For J=I To 25
Print" "
Next
For K=0 To 25-I
Print Left(Chr(90-I-K),1)
Next
Print;
Next

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Yabasic, 79 bytes

Another BASIC answer for Ya.

For I=0To 25
For J=I To 25
?" ";
Next
For K=0To 25-I
?Chr$(90-I-K);
Next
?
Next

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Recursiva, 50 24 23 22 bytes

{B26"P+*' '-L(}Z~}_(26

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Canvas, 6 bytes

Z[↔]R⇵

Try it here!

Explanation (characters have been changed to their ASCII forms to look monospace):

Z       push the uppercase alphabet
 [ ]    map over prefixes
  ↔       reverse horizontally
    R   pad each line with the line number spaces
     ⇵  and reverse the whole thing vertically
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PHP, 113 Bytes

Try it online!

Code, recursive function

function f($s=0){echo ($s<26)?str_pad("", $s)
.implode(array_reverse(range(chr(65), chr(65+$s))))."
".f($s+1):"";}

Explanation

function f($s=0){
  echo ($s<26)?           #it stops at the 26 letter
  str_pad("", $s)         #padding whitespace
  .implode(array_reverse(range(chr(65), chr(65+$s))))
                          #implode the range of letters,
                          #yes, range works with characters too
                          #reverse the array because it always starts with A  
  ."                      #concatenate a linebreak
   ".f($s+1):"";          #calling for the next letter
}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Go, 127 Bytes

package main;import."strings";func main(){for i:=26;i>0;i--{print("\n",Repeat(" ",i-1));for j:=i;j>0;j--{print(string(j+64))}}}

This prints with a leading newline.

Ungolfed and readable

package main
import . "strings"
func main(){
    for i := 26; i > 0; i-- {
        print("\n", Repeat(" ", i-1))
        for j := i; j > 0; j-- {
            print(string(j + 64))
        }
    }
}

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 82 bytes

	U =REVERSE(&UCASE)
O	OUTPUT =DUPL(' ',SIZE(U) - 1) U
	U LEN(1) REM . U	:S(O)
END	

Try it online!

Finally got around to a SNOBOL answer for this challenge. Always prints with a trailing newline.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Rust, 87 bytes

fn main(){for i in 0..26{println!("{:>1$}",&"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i..],51-2*i)}}

With Spaces and Indentation

fn main() {
    for i in 0..26 {
        println!("{:>1$}", &"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i..], 51-2*i)
    }
}

Try it online

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Emojicode, 156 bytes

🏁🍇🍦a🔤                         ZYXWVUTSRQPONMLKJIHGFEDCBA🔤🍮i 0🔁◀i 26🍇😀🍪🔪a i➖25 i🔪a➕i 25🐔a🍪🍮i➕i 1🍉🍉

Try it online!

Explanation:

🏁🍇     👴 start program
🍦a🔤                         ZYXWVUTSRQPONMLKJIHGFEDCBA🔤     👴 big ol string
🍮i 0           👴 declare loop variable
    🔁◀i 26🍇      👴 loop 26 times
        😀🍪         👴 print concatenated string 
        🔪a i➖25 i     👴 number of spaces
        🔪a➕i 25🐔a🍪     👴 reverse alphabet minus last letter
        🍮i➕i 1       👴 increment loop variable
    🍉              👴 end loop
🍉                 👴 end program
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

SmileBASIC 3, 67 64 bytes

-3 bytes from @12Me21 using the -I trick

Unfortunately the console is one character too narrow to fit the first line without wrapping the last character. Oh well.

FOR I=-25TO.?" "*-I+RIGHT$(@ZYXWVUTSRQPONMLKJIHGFEDCBA,-I+1)NEXT
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ There's a neat trick you can do to avoid STEP -1. Make the loop go from -25 to 0, and use -I instead of I. \$\endgroup\$ – 12Me21 Apr 25 '18 at 12:37

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.