Make an alphabet searchlight!

68

7

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>

MD XF

Posted 2017-09-05T19:38:49.057

Reputation: 11 605

4To me it looks like the light cast by the bat-signal – scottinet – 2017-09-05T19:47:14.123

4Closely Related. – Mr. Xcoder – 2017-09-05T20:26:09.793

Can each line have an extra space in front of it? – HyperNeutrino – 2017-09-05T20:35:55.440

@HyperNeutrino no. – MD XF – 2017-09-05T20:36:03.080

3Could each line have trailing spaces after the last letter? – miles – 2017-09-05T20:49:09.303

1@miles yes, that's fine. – MD XF – 2017-09-05T21:34:14.690

Can I add a leaderboard please, or @MDXF if you would like the override could you add it?

– jrtapsell – 2017-09-08T21:03:03.320

Answers

20

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

Adnan

Posted 2017-09-05T19:38:49.057

Reputation: 41 965

1I need to learn how asciicanvas work :-) – scottinet – 2017-09-05T20:10:41.423

2@MDXF IMO, that's a really dumb rule – James – 2017-09-05T20:20:51.623

3Hmm... I guess I'll remove the rule, then. [tag:status-completed] – MD XF – 2017-09-05T20:22:49.703

I feel like you should have asked what Miles has now asked since the question does state "produce this exact text".

– Jonathan Allan – 2017-09-05T20:55:04.067

@scottinet yeah there isn't any documentation yet, except for some answers on challenges :p. – Adnan – 2017-09-05T21:39:35.757

2I 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 – scottinet – 2017-09-06T08:39:16.393

6Why does žp exist when Au is golden? *BADUM* tissss – Magic Octopus Urn – 2017-09-06T17:44:18.693

@scottinet Yeah, documentation is not the strongest point of 05AB1E. If you could do that, that would be awesome! – Adnan – 2017-09-06T20:00:00.070

5Using 05AB1E, create a file documenting all of it's features, shortes code wins :P – Christian – 2017-09-08T08:30:36.040

2

@Christian at one point an empty program printed this haha. Edit, it still does xD.

– Magic Octopus Urn – 2018-01-31T18:25:38.443

@scottinet Only see this answer now (upvoted btw, nice answer!), but a few months back I created an explanation on how to use the 05AB1E Canvas on the 05AB1E tip page. :)

– Kevin Cruijssen – 2019-03-14T12:04:12.787

1@KevinCruijssen Yes, I have already upvoted it a while ago :). Thank you for doing that, as well as for the elaborate explanation of the compression techniques! – Adnan – 2019-03-14T12:12:49.630

22

R, 67 55 bytes

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

Try it online!

Giuseppe

Posted 2017-09-05T19:38:49.057

Reputation: 21 077

4R is beating Python on a string challenge? Nice. +1 for LETTERS – CriminallyVulgar – 2017-09-06T10:00:02.180

1@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. – CR Drost – 2017-09-08T20:13:09.217

-2 bytes if you change sep to s. Functions will autocomplete named arguments if there aren't collisions – Punintended – 2018-03-30T17:12:05.260

1@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 – Giuseppe – 2018-03-30T17:30:46.470

@Giuseppe I don't see a ... – MilkyWay90 – 2019-06-13T21:09:55.327

@MilkyWay90 the ... argument is a special one in R, representing a variadic argument list. cat in particular has the signature cat(...,file="",sep=" ",fill=FALSE,labels=NULL,append=FALSE). Named arguments are typically matched on the shortest unique substring, e.g., the call parse(t= <arg>) is equivalent to parse(text = <arg>). See page 44 of the Introduction to R for a bit more information.

– Giuseppe – 2019-06-13T21:17:20.703

@Giuseppe I see. I don't know how to program in R, so I thought there was an explicit ... – MilkyWay90 – 2019-06-13T21:21:18.757

17

Python 2, 57 bytes

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

Try it online!

Lynn

Posted 2017-09-05T19:38:49.057

Reputation: 55 648

16

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

James

Posted 2017-09-05T19:38:49.057

Reputation: 54 537

1I do these on my phone too, +1 – Stan Strum – 2017-09-05T22:45:22.867

13

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

AdmBorkBork

Posted 2017-09-05T19:38:49.057

Reputation: 41 581

11

Bash + GNU sed, 60

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

Try it online.

Digital Trauma

Posted 2017-09-05T19:38:49.057

Reputation: 64 644

You can save two bytes by changing :x to : and tx to t. – Jordan – 2017-10-30T01:02:20.057

10

///, 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

Jakube

Posted 2017-09-05T19:38:49.057

Reputation: 21 462

Same lengths as the C# and brainfuck answers :D – Conor O'Brien – 2017-09-07T00:30:22.703

9

Python 2, 66 64

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

Try it online!

Artemis_134

Posted 2017-09-05T19:38:49.057

Reputation: 89

1Welcome to Programming Puzzles & Code Golf - nice first answer! – MD XF – 2017-09-05T20:43:39.937

2Thanks! Figured I'd give it a try instead of just lurking. – Artemis_134 – 2017-09-05T20:45:17.673

2You can remove the space between print and ' for 65 bytes. – Mr. Xcoder – 2017-09-05T20:48:04.840

I ported your answer into Pyth, take a look: https://codegolf.stackexchange.com/a/141939/63757

– Stan Strum – 2017-09-07T02:40:16.197

9

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

nimi

Posted 2017-09-05T19:38:49.057

Reputation: 34 639

Why doesn't f['Z'..'A'] work? – Conor O'Brien – 2017-09-06T10:49:21.350

1@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. – nimi – 2017-09-06T16:09:14.623

Ah, I see now. Thanks! – Conor O'Brien – 2017-09-06T18:19:36.737

8

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 <<<<.
>>>]

Conor O'Brien

Posted 2017-09-05T19:38:49.057

Reputation: 36 228

7

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>

Arnauld

Posted 2017-09-05T19:38:49.057

Reputation: 111 334

I had wanted to suggest you an improvement, but then I realized that our approaches are very different. Hope you don't mind. – None – 2017-09-05T21:16:10.620

@ThePirateBay No problem! – Arnauld – 2017-09-05T21:17:18.667

7

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

HyperNeutrino

Posted 2017-09-05T19:38:49.057

Reputation: 26 575

13 bytes – Leaky Nun – 2017-09-05T20:32:13.627

@LeakyNun Oh right cool thanks! – HyperNeutrino – 2017-09-05T20:33:37.430

Yay, another use for the prefix quick. 12 bytes since mold will reshape here using the length implicitly.

– miles – 2017-09-05T20:37:16.733

@LeakyNun Actually, unfortunately that would make it invalid because there cannot be extra spaces (it would take 2 bytes to fix) – HyperNeutrino – 2017-09-05T20:37:25.843

6

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!

Luis Mendo

Posted 2017-09-05T19:38:49.057

Reputation: 87 464

@Sanchises Thanks! – Luis Mendo – 2017-09-07T11:21:25.560

6

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!

JosiahRyanW

Posted 2017-09-05T19:38:49.057

Reputation: 2 600

Why is this non-competing? – pppery – 2019-10-01T01:50:28.300

The language was created after the challenge. – JosiahRyanW – 2019-10-08T17:35:22.210

Hm, then I guess that gives me more motivation to use Poetic as a programming language! Heh. – JosiahRyanW – 2019-10-10T02:51:12.237

5

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

scottinet

Posted 2017-09-05T19:38:49.057

Reputation: 981

5

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).

Ramillies

Posted 2017-09-05T19:38:49.057

Reputation: 1 923

125...0 is the shorter way :-) – Massa – 2017-09-06T14:38:36.550

try say " "x$_,chrs $_+65...65 for 25...0 :-) – Massa – 2017-09-06T14:41:44.653

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.) – Ramillies – 2017-09-06T18:28:50.413

4

Charcoal, 19 11 bytes

-8 bytes thanks to ASCII-only.

F²⁶«P⮌…α⊕ι↗

Try it online! Link is to verbose version.

totallyhuman

Posted 2017-09-05T19:38:49.057

Reputation: 15 378

Wait noooooo there's leading space – ASCII-only – 2017-09-05T21:11:51.240

Son of a... I need to look through every single command and operator Charcoal has. >_> Thanks! – totallyhuman – 2017-09-05T21:11:53.133

Um... Is Mold even in the docs? – totallyhuman – 2017-09-05T21:15:25.350

Yes it is, although it's also called CycleChop, and it's a range overload so I may have forgotten to add it in – ASCII-only – 2017-09-05T21:16:23.293

We're still losing to 05ab1e so badly though :( – ASCII-only – 2017-09-05T21:19:12.203

wait better verbose version :P (and worse verbose version)

– ASCII-only – 2017-09-05T22:12:36.897

move :ur Move my what? :P The increment thing is much cleaner though. – totallyhuman – 2017-09-05T22:18:18.857

@ASCII-only you didn't forget it :p – Erik the Outgolfer – 2017-09-06T08:06:12.407

@EriktheOutgolfer ??? I didn't forget what – ASCII-only – 2017-09-06T08:40:45.027

1@ASCII-only CycleChop...but you forgot Increment (or whatever it's called) – Erik the Outgolfer – 2017-09-06T09:00:06.587

4

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.

MickyT

Posted 2017-09-05T19:38:49.057

Reputation: 11 735

4

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!

Dom Hastings

Posted 2017-09-05T19:38:49.057

Reputation: 16 415

4

Ruby, 54 52 bytes

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

Try it online!

Snack

Posted 2017-09-05T19:38:49.057

Reputation: 251

4

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 :)

Jacob Garby

Posted 2017-09-05T19:38:49.057

Reputation: 350

1A belated welcome to PPCG! nice answer! – Conor O'Brien – 2017-09-08T22:36:03.940

4

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!

Dennis

Posted 2017-09-05T19:38:49.057

Reputation: 196 637

4

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

BlackCap

Posted 2017-09-05T19:38:49.057

Reputation: 3 576

3

SOGL V0.12, 10 8 bytes

Z±{Xf}⁰¼

Try it Here!

dzaima

Posted 2017-09-05T19:38:49.057

Reputation: 19 048

Just curious, how long is the compressed version? – caird coinheringaahing – 2017-09-05T21:01:33.553

@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 – dzaima – 2017-09-05T21:12:33.093

3

Perl 5, 49 bytes

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

Try it online!

Xcali

Posted 2017-09-05T19:38:49.057

Reputation: 7 671

Looks like you're missing the first A, but seems that can be fixed by changing $"x25 to $"x26! – Dom Hastings – 2017-09-06T08:58:24.160

When I added the extra Z, I forgot to account for that. – Xcali – 2017-09-06T13:06:16.453

3

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!

user72349

Posted 2017-09-05T19:38:49.057

Reputation:

Save a byte by initializing b (b=''), then taking b out of the square brackets. – Rick Hitchcock – 2017-09-05T22:21:26.803

@RickHitchcock. Thanks. – None – 2017-09-05T22:27:34.350

3

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!

Renzo

Posted 2017-09-05T19:38:49.057

Reputation: 2 260

82 – ASCII-only – 2018-04-26T05:52:14.717

3

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.

CR Drost

Posted 2017-09-05T19:38:49.057

Reputation: 949

1That´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; – Titus – 2017-09-08T18:32:45.703

@Titus thanks, gave you a kudos in the answer. – CR Drost – 2017-09-08T20:08:53.757

nm. Just note that -R and -F are not free. See https://codegolf.meta.stackexchange.com/questions/2424/running-php-with-r-instead-of-code-tags/2428#2428

– Titus – 2017-09-09T09:04:51.377

I believe you can save a byte if you use $c<AA. – Ismael Miguel – 2017-09-20T19:25:49.630

@IsmaelMiguel Maybe you can; I can't. equality/comparison is going to be by strings, which is a lexical equality/comparison. The first invalid string is AA which is lexically between the valid strings A and B, making any comparator not work nicely. – CR Drost – 2017-09-20T19:30:17.660

@CRDrost Just saying "It doesn't seem like it will work because [...]" is enough... No need for your "Maybe you can; I can't." . . . – Ismael Miguel – 2017-09-20T19:39:16.320

1@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. – CR Drost – 2017-09-20T19:44:47.577

B is greater than AA. !$c[1] would work, but it doesn´t save anything. – Titus – 2018-04-21T20:49:23.867

3

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

Blue

Posted 2017-09-05T19:38:49.057

Reputation: 26 661

2

Python 2, 72 67 bytes

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

Try it online!

Rod

Posted 2017-09-05T19:38:49.057

Reputation: 17 588

This is why I love string literals - 65 bytes :P – Mr. Xcoder – 2017-09-05T20:46:36.563

2

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!

totallyhuman

Posted 2017-09-05T19:38:49.057

Reputation: 15 378

A reason behind the downvote, perhaps? – totallyhuman – 2017-09-05T20:44:06.073

Maybe because the language is really a glorified text compressor? I haven't downvoted fwiw – Conor O'Brien – 2017-09-06T10:48:13.197

2

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

J42161217

Posted 2017-09-05T19:38:49.057

Reputation: 15 931

CharacterRange should be shorter than FromCharacterCode. – JungHwan Min – 2017-09-05T22:00:47.487

it doesn't have "reverse" in it. If you can make it work without reverse please let me know – J42161217 – 2017-09-05T22:05:51.640

Reverse[CharacterRange[65,90]][[#-27;;]] is the same as Reverse@CharacterRange[65,91-#] – JungHwan Min – 2017-09-05T22:32:47.670

Also Reverse[ToUpperCase@Alphabet[][[;;27-i]]] can be reduced to ToUpperCase@Alphabet[][[-i;;1;;-1]] (got rid of Reverse!) – JungHwan Min – 2017-09-05T22:38:07.283

2

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

streetster

Posted 2017-09-05T19:38:49.057

Reputation: 3 635

2

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';}}

HatsuPointerKun

Posted 2017-09-05T19:38:49.057

Reputation: 1 891

Why would you int g=26 immediately before g=0? – MD XF – 2017-09-06T17:16:22.680

@MDXF For reasons that went out through the window when golfing, i guess :) – HatsuPointerKun – 2017-09-06T20:14:56.403

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. – Zacharý – 2017-09-09T13:33:47.287

You don't need a space between F and ' ' (but do need ASCII or compatible encoding). – Toby Speight – 2018-01-31T18:30:43.590

2

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!

sergiol

Posted 2017-09-05T19:38:49.057

Reputation: 3 055

Hmmm, I already golfed something similar on the "my italic" version of https://codegolf.stackexchange.com/a/110360/29325

– sergiol – 2017-09-05T23:55:36.583

The latest one appears to be wrong – ASCII-only – 2018-04-26T06:02:30.447

100? – ASCII-only – 2018-04-26T06:10:23.580

1-1 byte including set in the format. But I think your code doesn't answer the exact challenge. – david – 2018-11-24T13:02:46.623

1a proposition in 92 bytes though I think this possibly could be shortened with a unique string. – david – 2018-11-24T13:16:29.747

192 bytes with a single string per iteration – david – 2018-11-24T13:40:07.213

@ASCII-only: thanks for pointing my error – sergiol – 2018-11-25T00:12:27.240

@david: thanks for pointing my error – sergiol – 2018-11-25T00:12:41.613

2

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

Ismael Miguel

Posted 2017-09-05T19:38:49.057

Reputation: 6 797

2

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

Ven

Posted 2017-09-05T19:38:49.057

Reputation: 3 382

2You can reverse an array with W% (i.e. take every element starting from the end). – Martin Ender – 2017-09-07T14:02:55.637

Or -1% if W isn't sure to be -1. – Erik the Outgolfer – 2017-09-07T14:31:21.600

@MartinEnder Thanks! Fixed it that way (Now I wish I had a "reverse rang", hehe). – Ven – 2017-09-11T09:59:10.200

@EriktheOutgolfer shouldn't be an issue here (I also went the "functional" route), but thanks for the precision – Ven – 2017-09-11T09:59:30.607

2

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!

Ray

Posted 2017-09-05T19:38:49.057

Reputation: 1 488

2

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!

David Ljung Madison Stellar

Posted 2017-09-05T19:38:49.057

Reputation: 231

2

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!

Olivier Grégoire

Posted 2017-09-05T19:38:49.057

Reputation: 10 647

2

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.

Yalnix

Posted 2017-09-05T19:38:49.057

Reputation: 21

1Welcome to the site :) – Shaggy – 2017-09-28T09:42:57.070

2

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!

Jonah

Posted 2017-09-05T19:38:49.057

Reputation: 8 729

@FrownyFrog thanks! I was not aware of the negative trick with {. – Jonah – 2017-10-28T04:07:02.790

2

Haskell, 52 48 53 bytes

do x<-scanr(:)[]['Z','Y'..'A'];tail$(' '<$x)++x++"\n"

BlackCap

Posted 2017-09-05T19:38:49.057

Reputation: 3 576

1tails requires an import, though you can use scanr(:)[] instead: Try it online! – Laikoni – 2017-10-30T14:19:59.153

2

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!

Taylor Scott

Posted 2017-09-05T19:38:49.057

Reputation: 6 709

So much BASIC!! – MD XF – 2018-01-31T18:22:28.363

1@MDXF BASIC is Life!!!! – Taylor Scott – 2018-01-31T18:24:23.670

2

Python 3, 71 bytes

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

Try it online!

PikalaxALT

Posted 2017-09-05T19:38:49.057

Reputation: 41

2Welcome to PPCG! Nice first answer! – RedClover – 2018-04-21T15:10:06.083

2

Brachylog, 16 bytes

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

Try it online!

Prints with a single trailing newline.

Unrelated String

Posted 2017-09-05T19:38:49.057

Reputation: 5 300

1

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

caird coinheringaahing

Posted 2017-09-05T19:38:49.057

Reputation: 13 702

173 bytes – Mr. Xcoder – 2017-09-05T20:02:07.537

@Mr.Xcoder I forgot that the literal alphabet was shorter than import string – caird coinheringaahing – 2017-09-05T20:03:48.860

This prints the top line twice with an extra space. Change 26 to 25 to fix it – Cowabunghole – 2017-09-05T20:08:00.280

@Cowabunghole you saw nothing ;) – caird coinheringaahing – 2017-09-05T20:09:13.193

3I know porting Lynns would be shorter but for i in range(26):print(' '*(25-i)+"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i:]) saves another four bytes. – Jonathan Allan – 2017-09-05T21:39:57.413

1This approach gets down to 66 bytes:

i=26 while i:i-=1;print(' '*i+"ZYXWVUTSRQPONMLKJIHGFEDCBA"[-i-1:]) – awatts – 2017-09-05T23:53:57.360

@awatts You can replace the [-i-1:] with [~i:] to get it down to 64. – IFcoltransG – 2019-10-09T23:08:47.833

1

Japt, 17 16 bytes

;26Çn26 î +Bw tZ

Try it online!

Oliver

Posted 2017-09-05T19:38:49.057

Reputation: 7 160

Think you can save a byte with the equivalent of ;Bm_YnZl ... – ETHproductions – 2017-09-05T19:58:13.080

1

Pyth - 16 15 bytes

V_UG+*dN_<rG1hN

Try it online here.

Maltysen

Posted 2017-09-05T19:38:49.057

Reputation: 25 023

@Dave No, that is lowercase. Is that allowed? – Stan Strum – 2017-09-07T02:29:04.673

1

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.

Mr. Xcoder

Posted 2017-09-05T19:38:49.057

Reputation: 39 774

similar idea, but V_._Gs+m\ NrN1 is 14 btyes – Dave – 2017-09-07T02:52:25.270

1

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

Shaggy

Posted 2017-09-05T19:38:49.057

Reputation: 24 623

1

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!

scottinet

Posted 2017-09-05T19:38:49.057

Reputation: 981

172 bytes – Steadybox – 2017-09-05T21:49:01.613

You probably ought to mention that this is for ASCII or compatible environments. – Toby Speight – 2017-09-07T12:40:13.427

1

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

jstnthms

Posted 2017-09-05T19:38:49.057

Reputation: 181

I'm not sure a solution requiring specific user input is allowed. – MD XF – 2017-09-08T16:23:09.317

1

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!

MD XF

Posted 2017-09-05T19:38:49.057

Reputation: 11 605

1

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!

ATaco

Posted 2017-09-05T19:38:49.057

Reputation: 7 898

1

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

Brian

Posted 2017-09-05T19:38:49.057

Reputation: 1 209

1

VB, 167 bytes

i = 26

For a = i To 1 Step -1
    For j = a To 1 Step -1
        c = c + "  "
        b = b + Chr(64 + j)
    Next

    d = d & c & b & vbNewLine
    c = ""
    b = ""
Next
msgbox d

first time to participate but i'm not competing to everyone, just myself. lol

user74019

Posted 2017-09-05T19:38:49.057

Reputation: 27

2Welcome to PPCG! I am not sure about VB, but can you remove the whitespace, like b=b+Chr(64+j)? That would save quite a bit here. – JAD – 2017-09-06T08:11:57.193

@JarkoDubbeldam VB automatically adds spaces when programming in an IDE. I don't think they're required, though. I've seen confusion before about whether to remove them or ignore them. – mbomb007 – 2017-09-06T14:13:34.620

@mbomb007 hmm, can you run VB from a file without opening it in an IDE? – JAD – 2017-09-06T14:20:54.993

@JarkoDubbeldam When I deal with Basic's auto-indentation, I usually open a separate text editor, remove as much whitespace as possible, then paste that into the IDE. If auto-format still works and the code runs as expected, I post the code from the text editor. – steenbergh – 2017-09-06T14:40:56.890

This code can be consensed to something like: i=26┘ For a=iTo 1Step -1┘ For j=aTo 1Step -1┘ c=c+" "┘ b=b+Chr(64+j)┘ Next┘ d=d&c&b&Chr(13)┘ c=""┘ b=c┘ Next┘ msgbox d (used as line-breaks...) Note the FOR-instructions, Basic usually doesn't need a space beteen a number literal and the following instruction. – steenbergh – 2017-09-06T14:43:21.847

2Welcome to PPCG :) Following on from the other suggestions, there's plenty that can be golfed out of this. Here's a quick pass I took over it for 103 bytes: for a=26to 1step-1:c="":b="":for j=a to 1step-1:c=c+" ":b=b+chr(64+j):next:d=d&c&b&vbcrlf:next:msgbox d – Shaggy – 2017-09-06T16:47:26.237

1

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!

Grzegorz Puławski

Posted 2017-09-05T19:38:49.057

Reputation: 781

1

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

streetster

Posted 2017-09-05T19:38:49.057

Reputation: 3 635

1

Perl 6, 44 bytes

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

Try it online!

Massa

Posted 2017-09-05T19:38:49.057

Reputation: 189

1

QBIC, 48 bytes

[26|Q=Q+chr$(a+64)][26,1,-1|?space$(b)+_s_fQ|,-b

Explanation

[26|            FOR a = 1; a <= 26; a++
Q=Q+chr$(a+64)  Add to Q$ a chr() being a+64 (A-Z in succession)
]               NEXT (at the end of the loop, Q$ is ABC...XYZ)
[26,1,-1|       FOR b = 26; b >= 1; b--
?space$(b)      PRINT b spaces,
+_s             and a substring of
   _fQ|         Q$ reversed,
   ,-b          taking b characters from the right

steenbergh

Posted 2017-09-05T19:38:49.057

Reputation: 7 772

1

DUP, 48 bytes

25 65[^[$][32,1-]#%^^+[^^\-][$,1-]#,10,^][\1-\]#

Online DUP interpreter

M L

Posted 2017-09-05T19:38:49.057

Reputation: 2 865

1

Octave, 38 bytes (or 46 bytes in tio)

flip([spdiags(hankel(90:-1:65)) '']')'

Generates the correct output at least on windows installation of Octave, but in tio to be correctly shown the character 0 should be replace by space:

[max(32,flip(spdiags(hankel(90:-1:65))')') '']

Try it online!

rahnema1

Posted 2017-09-05T19:38:49.057

Reputation: 5 435

1

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

Brad Gilbert b2gills

Posted 2017-09-05T19:38:49.057

Reputation: 12 713

1

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.

Jerry

Posted 2017-09-05T19:38:49.057

Reputation: 71

1

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!

Chris

Posted 2017-09-05T19:38:49.057

Reputation: 31

1

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;
}

Jimmy Johnson

Posted 2017-09-05T19:38:49.057

Reputation: 71

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.

– JollyJoker – 2017-09-07T11:59:01.547

You can use n-> instead of ()-> even if there's no input. Using it to store a char inside the code might be ok. – JollyJoker – 2017-09-07T12:34:27.103

Thanks for the tips! I'll edit my answer in a few hours with your improvements. – Jimmy Johnson – 2017-09-07T12:46:55.537

You can copy / paste some lambda boilerplate from here

– JollyJoker – 2017-09-07T12:51:52.973

Avoid cast by using 'Z' instead of 90 and changing everything from int to char – JollyJoker – 2017-09-07T13:14:04.313

Have you tried compiling this? Because it doesn't compile... String() a() isn't valid in Java... – Olivier Grégoire – 2017-09-09T11:38:56.763

Even with copy pasta typos are possible :). Not sure why I added that, but it is fixed now. Thank you. – Jimmy Johnson – 2017-09-09T17:11:40.037

No problem! I allowed myself to edit your post, with a link towards an online interpreter. This is usually a good practice to show that no code issue happens! Also, your code is now 2 bytes shorter since you removed those (), but you hadn't updated your post with that, so I did it as well. – Olivier Grégoire – 2017-09-10T14:02:53.270

1

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.

Koppany Horvath

Posted 2017-09-05T19:38:49.057

Reputation: 41

13? 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]) – Stephen – 2017-09-06T23:11:37.430

1

Javascript, 82 bytes

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

Try it online!

Igor Sowinski

Posted 2017-09-05T19:38:49.057

Reputation: 29

1

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!

Stan Strum

Posted 2017-09-05T19:38:49.057

Reputation: 436

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? – Dave – 2017-09-07T03:13:50.387

@Dave similar to what answer? – Stan Strum – 2017-09-07T03:16:18.110

Yours! This being parent lol – Dave – 2017-09-07T03:16:41.890

@Dave I knew I was doing something wrong – Stan Strum – 2017-09-07T03:17:17.180

It's too early for this – Stan Strum – 2017-09-07T15:11:00.370

1

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.

Ismael Miguel

Posted 2017-09-05T19:38:49.057

Reputation: 6 797

1

Recursiva, 50 24 23 22 bytes

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

Try it online!

officialaimm

Posted 2017-09-05T19:38:49.057

Reputation: 2 739

1

Dyalog APL, 34 23 21 bytesSBCS

↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26

Try it online!

Thanks to Adám for the help!

Explanation:

↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26
                  ⍳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

Ven

Posted 2017-09-05T19:38:49.057

Reputation: 3 382

You have a stray . – Adám – 2017-09-07T12:18:26.200

Also, I'd write instead of . – Adám – 2017-09-07T12:19:40.427

Save two bytes: ↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26 – Adám – 2017-09-07T12:25:43.127

That's clever :). Ty. – Ven – 2017-09-07T12:32:19.880

1

Bash + coreutils, 64 bytes

printf '%s' {Z..A}|sed 'h;s/./ /g;G;s/ \n//;p;:a;s/ \b.//p;ta;Q'

Toby Speight

Posted 2017-09-05T19:38:49.057

Reputation: 5 058

I like this, but it seems to be missing the newline at the end. – Robert Benson – 2017-09-08T01:36:53.543

I guess the requirements were a bit unclear. – Robert Benson – 2017-09-08T02:04:46.883

1

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.

Toby Speight

Posted 2017-09-05T19:38:49.057

Reputation: 5 058

1

Husk, 15 bytes

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

Try it online!

-5 thanks to Zgarb. Still a newb :p

Erik the Outgolfer

Posted 2017-09-05T19:38:49.057

Reputation: 38 134

1

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.

Martin Ender

Posted 2017-09-05T19:38:49.057

Reputation: 184 808

1

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.

Robert Benson

Posted 2017-09-05T19:38:49.057

Reputation: 1 339

1

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!

david paavada

Posted 2017-09-05T19:38:49.057

Reputation: 11

I'm new so not familiar how to add a post, hope to help someone.!! :D – david paavada – 2017-09-08T10:40:24.143

1Also, the bytecount must be visible on the header. – Erik the Outgolfer – 2017-09-08T11:06:48.980

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. – peech – 2017-09-08T15:48:01.287

You can use public class M to save three bytes. And String[]a to save three more. – MD XF – 2017-09-08T16:16:04.560

1

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()
}

jrtapsell

Posted 2017-09-05T19:38:49.057

Reputation: 915

1

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

Taylor Scott

Posted 2017-09-05T19:38:49.057

Reputation: 6 709

1

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!

FantaC

Posted 2017-09-05T19:38:49.057

Reputation: 1 425

1

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!

Taylor Scott

Posted 2017-09-05T19:38:49.057

Reputation: 6 709

1

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!

Taylor Scott

Posted 2017-09-05T19:38:49.057

Reputation: 6 709

1

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!

Taylor Scott

Posted 2017-09-05T19:38:49.057

Reputation: 6 709

1

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

dzaima

Posted 2017-09-05T19:38:49.057

Reputation: 19 048

1

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
}

Francisco Hahn

Posted 2017-09-05T19:38:49.057

Reputation: 591

1

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!

Dust

Posted 2017-09-05T19:38:49.057

Reputation: 131

1

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.

Giuseppe

Posted 2017-09-05T19:38:49.057

Reputation: 21 077

1

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

snail_

Posted 2017-09-05T19:38:49.057

Reputation: 1 982

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. – 12Me21 – 2018-04-25T12:37:01.383

1

Stax, 13 9 bytes

á*↔?[O╒v4

Run and debug it at staxlang.xyz!

Unpacked (15 bytes) and explanation

VAr|]mc%Hv)
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)!

Khuldraeseth na'Barya

Posted 2017-09-05T19:38:49.057

Reputation: 2 608

1

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

Arcterus

Posted 2017-09-05T19:38:49.057

Reputation: 11

1

Emojicode, 156 bytes

a                         ZYXWVUTSRQPONMLKJIHGFEDCBAi 0◀i 26a i➖25 ia➕i 25ai➕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 25a      reverse alphabet minus last letter
        i➕i 1        increment loop variable
                   end loop
                  end program

X1M4L

Posted 2017-09-05T19:38:49.057

Reputation: 1 586

1

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)

Prettyfied:

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)

Try it online!

Tamás Sengel

Posted 2017-09-05T19:38:49.057

Reputation: 211

1

T-SQL, 115 bytes

DECLARE @ VARCHAR(51)=SPACE(25)+'ZYXWVUTSRQPONMLKJIHGFEDCBA'a:PRINT @
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.

BradC

Posted 2017-09-05T19:38:49.057

Reputation: 6 099

1

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

Hille

Posted 2017-09-05T19:38:49.057

Reputation: 349

1

K4, 22 bytes

Solution:

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

Explanation:

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 (')

Bonus:

Another 22 byte solution:

,/'(1_')\(25#$`;|.Q.A)

streetster

Posted 2017-09-05T19:38:49.057

Reputation: 3 635

1

><>, 51 49 bytes

2d*:&:1(?v:"@"+$1-48*}40.
l2(?vob1.>r~
-20.>~ao&1

Try it online!

Emigna

Posted 2017-09-05T19:38:49.057

Reputation: 50 798

1

Gaia, 14 bytes

26…v§&¦₵Av┅+†ṣ

Try it online!

Giuseppe

Posted 2017-09-05T19:38:49.057

Reputation: 21 077

1

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!

Value Ink

Posted 2017-09-05T19:38:49.057

Reputation: 10 608

0

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

Dorian

Posted 2017-09-05T19:38:49.057

Reputation: 1 521

0

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.

Bubbler

Posted 2017-09-05T19:38:49.057

Reputation: 16 616