77
\$\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

119 Answers 119

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\$
1
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\$
2
  • \$\begingroup\$ A reason behind the downvote, perhaps? \$\endgroup\$ Sep 5, 2017 at 20:44
  • \$\begingroup\$ Maybe because the language is really a glorified text compressor? I haven't downvoted fwiw \$\endgroup\$ Sep 6, 2017 at 10:48
2
\$\begingroup\$

Mathematica, 79 73 bytes

Column@(T=Table)[T[" ",26-i]<>ToUpperCase@Alphabet[][[-i;;1;;-1]],{i,26}]

or without Alphabet

Mathematica, 75 66 bytes

Column@Array[Table[" ",26-#]<>Reverse@CharacterRange[65,91-#]&,26] 

thanks @JungHwanMin for golfing more both of my answers

\$\endgroup\$
4
  • \$\begingroup\$ CharacterRange should be shorter than FromCharacterCode. \$\endgroup\$ Sep 5, 2017 at 22:00
  • \$\begingroup\$ it doesn't have "reverse" in it. If you can make it work without reverse please let me know \$\endgroup\$
    – ZaMoC
    Sep 5, 2017 at 22:05
  • \$\begingroup\$ Reverse[CharacterRange[65,90]][[#-27;;]] is the same as Reverse@CharacterRange[65,91-#] \$\endgroup\$ Sep 5, 2017 at 22:32
  • \$\begingroup\$ Also Reverse[ToUpperCase@Alphabet[][[;;27-i]]] can be reduced to ToUpperCase@Alphabet[][[-i;;1;;-1]] (got rid of Reverse!) \$\endgroup\$ Sep 5, 2017 at 22:38
2
\$\begingroup\$

K (oK), 31 27 bytes

Solution:

{`c$(x#32),65+|!x+1}@/:|!26

Try it online!

Explanation:

Iterate over the list of 25..0, each iteration create the reverse alphabet joined with x many spaces:

{`c$(x#32),65+|!x+1}@/:|!26 / solution
                        !26 / til 26 (0..25)
                       |    / reverse (25..0)
                    @/:     / each (25, 24, 23...)
{                  }        / lambda function
                x+1         / increment x (25->26)
               !            / til x (0..26)
              |             / reverse
           65+              / add 65, 0+65 = ASCII "A"
          ,                 / join
    (x#32)                  / x take 32 (e.g 32, x many times)
 `c$                        / cast everything to characters
\$\endgroup\$
2
\$\begingroup\$

SimpleTemplate, 102 bytes

This is just a very straight-forward implementation, nothing fancy.

{@setV 25}{@forfrom"Z"to"A"}{@callstr_repeat intoX" ",V}{@callrange intoZ _,"A"}{@echolX,Z}{@incby-1V}

Try it on http://sandbox.onlinephpfunctions.com/code/a31f7d1b8532385cc135cc1bf64e05d702ebcce4


Ungolded:

{@set spaces 25}
{@for i from "Z" to "A"}
    {@call str_repeat into padding " ", spaces}
    {@call range into letters i, "A"}
    {@echo EOL, padding, letters}
    {@inc by -1 spaces}
{@/}

Should be almost self-explainatory

\$\endgroup\$
2
\$\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.

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

vim, 46 bytes

:set nf=alpha
25a <ESC>aZ<ESC>qaylp<CTRL+X>q24@aqayyphxxq24@a

Ungolfed:

:set nf=alpha    " add letters to the set of number formats used by CTRL+A, CTRL+X
25a <ESC>aZ<ESC> " add the leading spaces and the Z
qaylp<CTRL+X>q   " record macro to copy and decrement the last letter, and
24@a             " run 24 times
qayyphxxq        " record macro to copy/paste the last line, and delete the last space and first letter. 
24@a             " run 24 times.

<ESC> and <CTRL+X> are 0x1B and 0x18 respectively.

Try it online!

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

Ruby, 60 bytes

I couldn't beat @Snack's answer, but here are some solutions that I found interesting:

25.downto 0{|i|$><<" "*i;i.downto 0{|e|$><<(65+e).chr};puts}

Try it online!

I'm also particularly entertained by calculating the spaces this way and was saddened that it wasn't shorter:

z="";(?A..?Z).each{|e| (?A..e).each{|k| z+=k}; z+=" "*(z.size**0.5-1)+?\n};puts z.reverse

At least it's the only answer that uses a square root!

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

Java (OpenJDK 8), 105 bytes

z->{for(int i=0;i<26;)System.out.printf("%"+(51-i*2)+"s%n","ZYXWVUTSRQPONMLKJIHGFEDCBA".substring(i++));}

Try it online!

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

C++, 146 142 141 140 137 133 bytes

-4 bytes thanks to MD XF

-4 bytes thanks to Zacharý

#include<iostream>
#define F for(i=26-g;i;--i)std::cout<<
void f(){for(int g=1,i;g<27;g+=2){F ' ';--g;F char(64+i);std::cout<<'\n';}}
\$\endgroup\$
4
  • \$\begingroup\$ Why would you int g=26 immediately before g=0? \$\endgroup\$
    – MD XF
    Sep 6, 2017 at 17:16
  • \$\begingroup\$ @MDXF For reasons that went out through the window when golfing, i guess :) \$\endgroup\$ Sep 6, 2017 at 20:14
  • \$\begingroup\$ Changing the last two lines to #define F for(i=26-g;i;--i)std::cout<< and void f(){for(int g=1,i;g<27;g+=2){F ' ';--g;F char(64+i);std::cout<<'\n';}} should save you a few bytes. \$\endgroup\$
    – Adalynn
    Sep 9, 2017 at 13:33
  • \$\begingroup\$ You don't need a space between F and ' ' (but do need ASCII or compatible encoding). \$\endgroup\$ Jan 31, 2018 at 18:30
2
\$\begingroup\$

Python 3, 69 bytes

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

Try it online!

This is my first challenge. I hope i've done this right.

Edit: Had a 26 where a 25 should have been.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to the site :) \$\endgroup\$
    – Shaggy
    Sep 28, 2017 at 9:42
2
\$\begingroup\$

Haskell, 52 48 53 bytes

do x<-scanr(:)[]['Z','Y'..'A'];tail$(' '<$x)++x++"\n"
\$\endgroup\$
1
  • 1
    \$\begingroup\$ tails requires an import, though you can use scanr(:)[] instead: Try it online! \$\endgroup\$
    – Laikoni
    Oct 30, 2017 at 14:19
2
\$\begingroup\$

J, 21 bytes

({.~1-2*#)\.u:90-i.26

Try it online!

original version

(,~' '#~<:@#)\.|.26$65|.a.
  • 26$65|.a. get A - Z
  • |. reverse them
  • \. take successive prefixes from the right side
  • (,~' '#~<:@#) append to each one (,~) a number of spaces equal to the length of the prefix minus 1 (<:@#)

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ @FrownyFrog thanks! I was not aware of the negative trick with {. \$\endgroup\$
    – Jonah
    Oct 28, 2017 at 4:07
2
\$\begingroup\$

Visual Basic .NET (Mono), 134 bytes

Module M
Sub Main
Dim S,I,J
For I=0To 25
S=Space(25-I)
For J=0To 25-I
S+=Chr(90-I-J)
Next
Console.WriteLine(S)
Next
End Sub
End Module

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ So much BASIC!! \$\endgroup\$
    – MD XF
    Jan 31, 2018 at 18:22
  • 1
    \$\begingroup\$ @MDXF BASIC is Life!!!! \$\endgroup\$ Jan 31, 2018 at 18:24
2
\$\begingroup\$

Python 3, 71 bytes

for x in range(26):print(' '*(25-x),*map(chr,range(90-x,64,-1)),sep='')

Try it online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to PPCG! Nice first answer! \$\endgroup\$
    – RedClover
    Apr 21, 2018 at 15:10
2
\$\begingroup\$

Tcl, 140 bytes

Still very ungolfed, will do it later!

set n 26;time {set c $n;append s [string repe \  $n];incr n -1;time {append s [format %c [expr 65+[incr c -1]]]} $c; append s \n} 26;puts $s

Try it online!


Tcl, 142 bytes

set n 26;while \$n {set c $n;append s [string repe \  $n];incr n -1;time {append s [format %c [expr 65+[incr c -1]]]} $c; append s \n};puts $s

Try it online!

\$\endgroup\$
8
  • \$\begingroup\$ Hmmm, I already golfed something similar on the "my italic" version of codegolf.stackexchange.com/a/110360/29325 \$\endgroup\$
    – sergiol
    Sep 5, 2017 at 23:55
  • \$\begingroup\$ The latest one appears to be wrong \$\endgroup\$
    – ASCII-only
    Apr 26, 2018 at 6:02
  • 1
    \$\begingroup\$ -1 byte including set in the format. But I think your code doesn't answer the exact challenge. \$\endgroup\$
    – david
    Nov 24, 2018 at 13:02
  • 1
    \$\begingroup\$ a proposition in 92 bytes though I think this possibly could be shortened with a unique string. \$\endgroup\$
    – david
    Nov 24, 2018 at 13:16
  • 1
    \$\begingroup\$ 92 bytes with a single string per iteration \$\endgroup\$
    – david
    Nov 24, 2018 at 13:40
2
\$\begingroup\$

Brachylog, 16 bytes

∧Ẓa₁ụ?b{~wṢ}ᵐ&ẉ⊥

Try it online!

Prints with a single trailing newline.

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

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
\$\endgroup\$
2
+50
\$\begingroup\$

Vyxal, 9 bytes

kA¦₄ʁ꘍RṘ⁋

Try it Online!

could be -1 byte by replacing the at the end with the j flag

-4 bytes from the initial working version thanks to ovs
some golfs were proposed by other people but they broke the answer
-2 bytes thanks to Aaron Miller

kA¦₄ʁ꘍RṘ    Full Program
kA          "ABC...XYZ"
  ¦         "A", "AB", "ABC", ..., "ABC...XYZ"
   ₄        26
    ʁ       0..25
     ꘍      a + " " * b (returns "A", "AB ", "ABC  ", ...)
      R     Reverse each ("A", " BA", "  CBA", ...)
       Ṙ    Reverse the entire list
        ⁋   Join on newlines
\$\endgroup\$
9
  • 1
    \$\begingroup\$ 9 bytes \$\endgroup\$
    – lyxal
    May 2, 2021 at 1:30
  • \$\begingroup\$ @Lyxal i refuse to turn to the dark side of (ab)using flags :P \$\endgroup\$
    – hyper-neutrino
    May 2, 2021 at 3:03
  • 1
    \$\begingroup\$ fine then. 10 bytes flagless \$\endgroup\$
    – lyxal
    May 2, 2021 at 3:05
  • \$\begingroup\$ kA should be kZ since the alphabet is supposed to be backwards. \$\endgroup\$ May 2, 2021 at 3:38
  • 1
    \$\begingroup\$ 8 bytes \$\endgroup\$ Jul 19, 2021 at 16:04
2
\$\begingroup\$

CJam, 25 bytes

Fixed. Thanks to Martin Ender for the help fixing it!

'[,65>W%_,,_Sf*W%\@f>.+N*

Try it online!

Explanation:

'[,65>W%_,,_Sf*W%\@f>.+N*
'[,65>                     e# From the cjam golfing tips, generate A-Z
      W%                   e# Reverse the array: Z-A
        _,                 e# Take the size of that range (so, 26)
          ,                e# Make a range 0..25
           _               e# Dupe that range
              f*           e# For each value of that range
             S             e# Repeat a space that amount of times
                W%         e# Reverse this list of strings
                  \        e# Swap the top and the second elements of the stack
                   @       e# Brings the first stack el. to the top
                    f>     e# For each value in that range, remove N elements from the alphabet (generate ZYX..., until, CBA, BA, A).
                      .+   e# Vectorized append (appends space with the alphabet chunks)
                        N* e# Join with newline
                   
            
\$\endgroup\$
4
  • 2
    \$\begingroup\$ You can reverse an array with W% (i.e. take every element starting from the end). \$\endgroup\$ Sep 7, 2017 at 14:02
  • \$\begingroup\$ Or -1% if W isn't sure to be -1. \$\endgroup\$ Sep 7, 2017 at 14:31
  • \$\begingroup\$ @MartinEnder Thanks! Fixed it that way (Now I wish I had a "reverse rang", hehe). \$\endgroup\$
    – Ven
    Sep 11, 2017 at 9:59
  • \$\begingroup\$ @EriktheOutgolfer shouldn't be an issue here (I also went the "functional" route), but thanks for the precision \$\endgroup\$
    – Ven
    Sep 11, 2017 at 9:59
1
\$\begingroup\$

Pyth - 16 15 bytes

V_UG+*dN_<rG1hN

Try it online here.

\$\endgroup\$
1
  • \$\begingroup\$ @Dave No, that is lowercase. Is that allowed? \$\endgroup\$
    – Stan Strum
    Sep 7, 2017 at 2:29
1
\$\begingroup\$

Python 3, 84 80 73 bytes

for i in range(25,-1,-1):print(' '*i+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i::-1])

Try it online!

Saved 7 bytes thanks to @Mr. Xcoder

\$\endgroup\$
7
  • 1
    \$\begingroup\$ 73 bytes \$\endgroup\$
    – Mr. Xcoder
    Sep 5, 2017 at 20:02
  • \$\begingroup\$ @Mr.Xcoder I forgot that the literal alphabet was shorter than import string \$\endgroup\$ Sep 5, 2017 at 20:03
  • \$\begingroup\$ This prints the top line twice with an extra space. Change 26 to 25 to fix it \$\endgroup\$ Sep 5, 2017 at 20:08
  • 3
    \$\begingroup\$ I know porting Lynns would be shorter but for i in range(26):print(' '*(25-i)+"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i:]) saves another four bytes. \$\endgroup\$ Sep 5, 2017 at 21:39
  • 1
    \$\begingroup\$ This approach gets down to 66 bytes: i=26 while i:i-=1;print(' '*i+"ZYXWVUTSRQPONMLKJIHGFEDCBA"[-i-1:]) \$\endgroup\$
    – awatts
    Sep 5, 2017 at 23:53
1
\$\begingroup\$

Pyth, 15 bytes

j_.e+*kd_rb1._G

Try it online!


Explanation

  • j_.e+*kd_rb1._G - Full program.

  • ._G - Prefixes of the lowercase alphabet.

  • .e - Enumerated map, with k as the indexes and b as the values.

  • *kd - A space repeated a number of times equal to the current index.

  • _rb1 - And the current element converted to uppercase.

  • + - String concatenation.

  • _ - Reverse.

  • j - Join by newlines.

\$\endgroup\$
1
  • \$\begingroup\$ similar idea, but V_._Gs+m\ NrN1 is 14 btyes \$\endgroup\$
    – Dave
    Sep 7, 2017 at 2:52
1
\$\begingroup\$

Japt, 17 16 bytes

;26Çn26 î +Bw tZ

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Think you can save a byte with the equivalent of ;Bm_YnZl ... \$\endgroup\$ Sep 5, 2017 at 19:58
1
\$\begingroup\$

PHP, 82 bytes

$l=strlen($s=$argv[1]);while($l)echo strrev(str_pad(substr($s,0,$l),$l+$l--))."
";

Called with ABCDEFGHIJKLMNOPQRSTUVWXYZ as an argument.

Do I get bonus points because it produces the desired effect with any string? :P

\$\endgroup\$
1
  • \$\begingroup\$ I'm not sure a solution requiring specific user input is allowed. \$\endgroup\$
    – MD XF
    Sep 8, 2017 at 16:23
1
\$\begingroup\$

RProgN 2, 17 bytes

AL«]' '*\A\ùi.‹»;

Explained

AL«]' '*\A\ùi.‹»;
AL                  # Length of the Alphabet, 26.
  «            »;   # For each, numbers 1 through 26 inclusive.
   ]                # Duplicate the index eg.                   (5, 5)
    ' '*            # Repeat ' ' by the index.                  (5, '     ')
        \           # Flip the top of the stack,                ('     ', 5)
         A\         # Push the alphabet under the top.          ('     ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 5)
           ù        # Get the first n characters.               ('     ', 'ABCDE')
            i       # Reverse the top of the stack.             ('     ', 'EDCBA')
             .      # Concatenate.                              ('     EDCBA')
              ‹     # Rotate left, to remove the extra space.   ('    EDCBA ')

This leaves each result on the stack, and RProgN2 implicitely prints the stack upside down, which conveniently gives us our result.

Try it online!

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

C (gcc), 75 72 bytes

-3 bytes thanks to Steadybox

i=27;main(j){for(;--i;)for(printf("\n%*c",j=i,64+i);--j;putchar(64+j));}

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 72 bytes \$\endgroup\$
    – Steadybox
    Sep 5, 2017 at 21:49
  • \$\begingroup\$ You probably ought to mention that this is for ASCII or compatible environments. \$\endgroup\$ Sep 7, 2017 at 12:40
  • \$\begingroup\$ 67 bytes: i=27;main(j){for(;j=--i*2;)for(puts("");--j;putchar(j>i?32:64+j));} \$\endgroup\$
    – jdt
    Aug 13, 2021 at 19:23
1
\$\begingroup\$

SpecBAS - 89 bytes

1 s=25,a$="ZYXWVUTSRQPONMLKJIHGFEDCBA"
2  ?" "*s;a$
3 a$=a$(2 TO),s-=1
4 IF s>0 THEN 2
5  ?a$

Bit of string splicing, rinse and repeat

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

C# (.NET Core), 87 + 18 bytes

_=>new int[26].Select((x,i)=>"ZYXWVUTSRQPONMLKJIHGFEDCBA".Substring(i).PadLeft(51-2*i))

Also included in byte count:

using System.Linq;

Try it online!

This outputs a collection of strings (for each line).

Explanation:

_ =>                                   // A function that takes one argument (unused)
    new int[26].                       // Create new collection size 26
    Select((x, i) =>                   // Replace every member with
        "ZYXWVUTSRQPONMLKJIHGFEDCBA"   //    Our alphabet
        .Substring(i)                  //    Take it's part based on line number
        .PadLeft(51 - 2 * i)           //    Add spaces to the left
    )

Here's non-kolmogorov version (for any string) - 76 + 18 bytes:

a=>new int[a.Length].Select((x,i)=>a.Substring(i).PadLeft(a.Length*2-1-2*i))

Try it online!

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

Perl 6, 44 bytes

$_=chrs 32 xx 27,91...65;.say while s/\s\S//

Try it online!

\$\endgroup\$

Your Answer

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

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