Diagonal Alphabet

67

9

Given no input, your task is to generate the following:

a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
                q
                 r
                  s
                   t
                    u
                     v
                      w
                       x
                        y
                         z

Nonvisually, your task is to generate each letter in the alphabet, with spaces before it equal to its position in the alphabet minus one.

If you print this, it must appear like the above. Extraneous whitespace that does not affect appearance, as well as a trailing newline, is allowed. You can use all lowercase, or all uppercase.

You may also return this from a function as per usual rules, either as a string with newlines, or a list of strings.

This is , so shortest answer in bytes wins!

Stephen

Posted 2017-06-08T01:35:23.157

Reputation: 12 293

Do the spaces need to be real ASCII spaces, or can I give output like a<VERTICAL-TAB>b<VERTICAL-TAB>c...? How about if there are some backspace characters in there too? As long as the visual result is the same? – Digital Trauma – 2017-06-08T23:30:08.280

@DigitalTrauma as long as it appears the same, I don't care what kind of whitespace you use. – Stephen – 2017-06-08T23:31:43.877

Can I use tabs instead of spaces? – None – 2017-06-09T23:28:10.500

@yamboy1 hmm, probably not. Most tabs are set to a large number of spaces - if your diagonal looks like it has 4 spaces before the b, it won't look very diagonal. If it looks like the slope is ~-1 then it's fine. – Stephen – 2017-06-09T23:32:52.520

does not affecting appearance include having an extra leading space or 2? – MildlyMilquetoast – 2017-09-11T17:08:17.200

@MistahFiggins sure, as long as they are on every line – Stephen – 2017-09-11T17:12:16.403

Answers

86

Charcoal, 2 bytes

↘β

Try it online!

How?

 β - the lowercase alphabet
↘  - direction

Exactly the kind of challenge for which Charcoal was originally designed.

Jonathan Allan

Posted 2017-06-08T01:35:23.157

Reputation: 67 804

4The right language :) – Stephen – 2017-06-08T01:44:35.497

2

This reminds me, I should probably work on Crayon some more... I believe ↘"abc ... xyz"q would be the shortest working program. (Try it online!) ↘``26O;)q should work (start with a backtick; for each I in 0...25, pop the implicit I, increment the backtick and output), but it throws an "empty stack" error for some reason...

– ETHproductions – 2017-06-08T01:51:10.557

2

2 bytes?! In what encoding is the SOUTH EAST ARROW a single byte?

– Wyck – 2017-06-08T13:00:25.373

6

@Wyck Charcoal (note: speculation) uses a custom code page, which can be compressed to 1 byte instructions. That's legitimate for Code Golf. https://codegolf.meta.stackexchange.com/questions/9428/when-can-apl-characters-be-counted-as-1-byte-each

– Draco18s no longer trusts SE – 2017-06-08T13:12:33.180

1

@Wyck Charcoal custom code page

– Stephen – 2017-06-08T15:45:26.960

@Wyck oops, yes I meant to add a link to the code-page via "bytes" in the header! – Jonathan Allan – 2017-06-08T20:00:01.340

@Draco18s - thanks – Jonathan Allan – 2017-06-08T20:00:46.923

14@StephenS, I think you mean the bottom-right language :) – Wossname – 2017-06-09T21:29:23.817

18

C, 45 bytes

f(i){for(i=0;++i<27;)printf("%*c\n",i,i+96);}

Thanks to @Dennis for saving 5 bytes!

Doorknob

Posted 2017-06-08T01:35:23.157

Reputation: 68 138

9Works on my machine™ – Destructible Lemon – 2017-06-08T02:08:16.480

I think you'd have to initialize or reset i at some point. At least on TIO, f() only works once.

– Dennis – 2017-06-08T02:37:14.227

@Dennis Ah, you're right. Fixed that. – Doorknob – 2017-06-08T02:46:47.100

f(i){for(i=0;++i<27;printf("%*c\n",i,i+96));} saves a few bytes. – Dennis – 2017-06-08T03:38:09.753

f(i){for(;++i<28;)printf("%*c\n",i-1,i+95);} saves one byte. – user41805 – 2017-06-08T11:20:31.667

42 bytes: f(i){for(;i<27;)printf("%*c\n",i++,i+96);} – Steadybox – 2017-06-08T17:02:03.477

@KritixiLithos That relies on 0 being previously stored in the register used for passing the first argument, which is not always the case, so it doesn't work all the time. Try it online!

– Doorknob – 2017-06-08T17:29:48.333

(cc @Steadybox) – Doorknob – 2017-06-08T17:29:55.870

i;f(){while(++i<27)printf("%*c\n",i,i+96);} saves a few bytes. – MD XF – 2017-06-09T03:16:58.887

@MDXF No, that is essentialy what I had previously and does not work because it renders the function unable to be called multiple times. – Doorknob – 2017-06-09T04:11:46.363

Do we have a rule requiring a function to be able to be called multiple times? – MD XF – 2017-06-09T04:12:16.590

@MDXF Yes, we have.

– Steadybox – 2017-06-10T11:08:04.477

3f(i){for(i=96;i<122;)printf("%c\v",++i);} for 41 bytes - make sure to run this on an actual terminal (yes, this is allowed) – NieDzejkob – 2018-01-15T16:39:22.813

13

05AB1E, 14 8 6 bytes

-2 bytes thanks to @Emigna

AvyNú»

How it works

A      # lowercase alphabet
 v     # for letter in alphabet
  y    # push letter
   N   # push index of letter
    ú  # Pad letter with index of letter spaces
     » # Join with stack on newline.

Try it online!

Original version, 14 bytes

26FNð×N65+ç«}»

Neil A.

Posted 2017-06-08T01:35:23.157

Reputation: 2 038

You can save another 2 bytes with AvyNú». – Emigna – 2017-06-08T06:09:55.893

@Emigna: Thanks! Will edit that in. – Neil A. – 2017-06-08T06:37:03.867

ƶ seems so perfect, but it's not :(. – Magic Octopus Urn – 2017-06-08T14:28:10.933

Λ probably wasn't available yet at the time, but 26A3Λ saves a byte. – Kevin Cruijssen – 2018-05-08T08:35:05.560

@KevinCruijssen AgA3Λ was my first thought :P. – Magic Octopus Urn – 2018-07-10T15:59:04.197

@KevinCruijssen didn't even notice my previous comment. So I guess it was technically my second thought xD – Magic Octopus Urn – 2018-07-10T16:39:24.280

1

@MagicOctopusUrn ₂A3Λ would have been even shorter.

– Kevin Cruijssen – 2018-08-12T14:45:50.377

@KevinCruijssen oooo... 26 is a built-in now! Nice call. – Magic Octopus Urn – 2018-08-12T20:27:32.200

12

JavaScript (ES6), 60 59 bytes

f=(n=10)=>n-36?" ".repeat(n-10)+n.toString(++n)+`
`+f(n):""

A recursive function which returns a string with a trailing newline.

ETHproductions

Posted 2017-06-08T01:35:23.157

Reputation: 47 880

1Whoa, that's so sneaky. Converting a number in the range 10 to 36 to a number in a weird base. Don't understand yet why the base has to increase too though. – Steve Bennett – 2017-06-08T02:22:54.080

@SteveBennett Because n.toString(n) is always "10" :P (within 2...36, that is) – ETHproductions – 2017-06-08T02:24:22.893

Yeah, but n.toString(36) gives the right result, for n in 10..35? – Steve Bennett – 2017-06-08T02:26:21.617

2@SteveBennett Correct, but n.toString(++n)+f(n) is a byte shorter than n.toString(36)+f(n+1). – ETHproductions – 2017-06-08T02:27:13.960

1You could do f=(n=10,s='')=>n-36?s+n.toString(++n)+'\n'+f(n,s+' '):"" for 55. – Arnauld – 2017-06-08T06:39:42.220

1Save a byte with some ES8: "".padEnd(n-10)+n.toString(++n). – Shaggy – 2017-06-08T08:09:23.020

1@Arnauld, f=(n=10,s='')=>n-36?s+n.toString(++n)+'\n'+f(n,s+' '):s would seem to be permissible. – Shaggy – 2017-06-08T08:37:16.290

@Shaggy I suppose it is. This doesn't seem to break the rules. – Arnauld – 2017-06-08T08:54:13.077

If only a leading newline had been allowed, you could have used f=(n=10,s='\n')=>n-36?s+n.toString(++n)+f(n,s+' '):''. – Neil – 2017-06-08T09:19:18.673

@Neil even f=(n=10,s='')=>n-36?s+n.toString(++n)+'\n'+f(n,s+' '):'' is shorter – l4m2 – 2018-03-04T17:57:25.280

@Shaggy Can't you replace '\n' with a backtick newline? – Oliver – 2018-04-23T15:15:51.240

Yes, @Oliver. I only used \n above because you can't have newlines in comments and the single quotes are because there doesn't seem to be a way to escape backticks in comments. – Shaggy – 2018-04-23T15:19:08.957

12

Ruby, 28 bytes

26.times{|a|puts" "*a<<97+a}

Try it online!

Explanation:

The << operator on a string in Ruby does the trick, as explained in the Documentation

  • str << integer → str

  • str << obj → str

Append—Concatenates the given object to str. If the object is a Integer, it is considered as a codepoint, and is converted to a character before concatenation.

G B

Posted 2017-06-08T01:35:23.157

Reputation: 11 099

12

R, 38 37 36 bytes

write(intToUtf8(diag(65:90),T),1,26)

(The use of write is inspired by @Giuseppe's answer.)

Sven Hohenstein

Posted 2017-06-08T01:35:23.157

Reputation: 2 464

3I swear I tried that but couldn't get it to work! Well done. You can save 1 byte by using 65:90, since upper case is allowed. – user2390246 – 2017-06-08T13:56:46.027

@user2390246 Thanks for pointing out! – Sven Hohenstein – 2017-06-08T14:13:28.780

you can use 1 rather than "" to shave off another byte. – Giuseppe – 2018-04-12T23:22:39.340

@Giuseppe Thanks for pointing out! – Sven Hohenstein – 2018-04-13T04:40:09.120

11

Python 2, 36 bytes

n=65;exec"print'%*c'%(n,n);n+=1;"*26

This takes advantage of the extraneous whitespace that does not affect appearance rule.

Try it online!

Alternate version, 38 bytes

n=1;exec"print'%*c'%(n,n+96);n+=1;"*26

This produces the exact output from the challenge spec.

Try it online!

Dennis

Posted 2017-06-08T01:35:23.157

Reputation: 196 637

How does %*c even work? – Leaky Nun – 2017-06-08T04:22:46.207

%*<identifier> takes two arguments: the length to pad it to and the actual thing to substitute. Some printf implementations have even more obscure features, such as the %1$<identifier> I used here. – Dennis – 2017-06-08T04:32:22.837

11

Vim, 29 bytes

:h<_↵↵↵y$ZZ25o <Esc>{qqpblD+q25@q

Try it online!

↵ means press the return key

< Esc> means press the escape key

How does this work?

:h<_↵↵↵                             Open the help and navigate to the alphabet
       y$ZZ                         Copy the alphabet and close the help
           25o <Esc>                Abuse auto-indent and create a whitespace diagonal
                    gg              Go to the beginning of the file
                      qq            Record a macro
                        pb          Paste the alphabet and go to the first letter
                          lD        Go to the second letter and cut the rest of the alphabet
                            +       Go to the first non-blank character in the next line
                             q      Stop recording the macro
                              25@q  Run the macro for the remaining letters

jmriego

Posted 2017-06-08T01:35:23.157

Reputation: 381

Try it online! You can use this to demonstrate it (V is based on Vim and mostly backwards compatible except apparently autoindent defaults to off). Also, less important, you missed the + in your explanation which threw me for a second. – nmjcman101 – 2017-06-08T11:36:50.400

Thanks @nmjcman101! I was trying to find some way to try vim online and never knew that about V – jmriego – 2017-06-08T12:26:35.167

You can use instead of <Esc>. It looks a little better in my opinion. – Post Rock Garf Hunter – 2017-06-08T14:05:21.560

You can save one byte if you do { instead of gg – James – 2017-06-08T21:24:00.720

You could use 2↵ instead of ↵↵↵ and maybe Y instead of y$ – G B – 2017-06-09T06:08:29.907

Thanks @DJMcMayhem! Saved one byte with that. The reason why I can't use the Y instead of y$ is because it would yank also a newline and would have to delete it after every paste. So it would be similar unless I can think of something else. – jmriego – 2017-06-09T08:12:37.547

@WheatWizard: how do you type your diagonal Esc ? using kbd tag ? <kbd>Esc</kbd> – Olivier Dulac – 2017-06-09T13:28:16.017

@OlivierDulac I copied it and pasted it. It is unicode 241B

– Post Rock Garf Hunter – 2017-06-09T13:31:16.600

That's strange. I see that character as an horizontal "ESC". It definitelly looks better in other fonts – jmriego – 2017-06-09T14:18:45.727

9

PHP, 39 bytes

for($s=a;!$s[26];$s=" ".++$s)echo"$s
";

user63956

Posted 2017-06-08T01:35:23.157

Reputation: 1 571

This is rather verbose :) Here's mine

– aross – 2017-06-28T15:55:19.307

8

Pure Bash, 13

echo {a..z}^K^H

Here ^K and ^H are literal vertical tab and backspace ASCII control characters. The xxd dump of this script is as follows - use xxd -r to regenerate the actual script:

00000000: 6563 686f 207b 612e 2e7a 7d0b 08         echo {a..z}..
  • {a..z} is a standard bash brace expansion to produce a b c ... z (space separated)
  • the ^K vertical tab drops the cursor down one line to the same position
  • the ^H backspace moves the cursor back one to erase the separator space

Try it online. col and tac are used in the footer to get this to render correctly in a browser window, but this is unnecessary in a regular terminal.


If the above unorthodox control characters in the output are too much of a stretch for you, then you can do this:

Bash + common utilities, 24

echo {a..z}^K^H|col -x|tac

Here ^K and ^H are literal vertical tab and backspace ASCII control characters. The xxd dump of this script is as follows - use xxd -r to regenerate the actual script:

00000000: 6563 686f 207b 612e 2e7a 7d0b 087c 636f  echo {a..z}..|co
00000010: 6c20 2d78 7c74 6163                      l -x|tac

Try it online. The vertical tab and backspace may be rendered invisible by your browser, but they are there (invisible on chrome, visible on firefox).

  • col -x re-renders the input such that funny control characters are replaced with spaces and newlines to give the same visual result
  • for some reason col outputs lines in reverse order. tac corrects that.

Digital Trauma

Posted 2017-06-08T01:35:23.157

Reputation: 64 644

That is very cool :) (and thanks to meta and @Dennis for suggesting sorting answers on codegolf by activity instead of score, to have better answers come up instead of the (very boring) codegolf langages builtins ones : https://codegolf.meta.stackexchange.com/questions/10127/how-can-we-help-users-who-are-put-off-by-the-use-of-golfing-languages#comment32362_10132)

– Olivier Dulac – 2017-06-09T13:35:18.903

Many terminals render ^K as cursor up, which is the behaviour that col must be emulating here. – Neil – 2017-06-12T15:24:10.437

@Neil yes, that makes sense - the col manpage calls a VT a "reverse line feed". xterm, gnome-terminal and OSX terminal all drop down a line though... – Digital Trauma – 2017-06-12T18:04:50.247

8

Brain-Flak, 124, 116, 106 bytes

((((()))))(((([][]){}){})[[]()]<>){(({})<(({})<({}<>({})({})<>)>)
{({}<(<>({})<>)>[()])}{}(<>[][]<>)>[()])}

Try it online!

Explanation:

This answer abuses the Stack Height Nilad, but in a new way that I've never used before, which I'm pretty proud of. Other than that, the answer's not too clever.

So analyzing the characters used in this ASCII art, there are really three values that are frequently used:

  • 32 (space),

  • 64 (add 64 to N to get the N'th letter of the alphabet), and

  • 10 (newline)

As well as 26. (number of loops) And these numbers are pushed in different locations, so we can't really reuses intermediate values to make the large numbers smaller. And pushing all for of these numbers is a whopping 86 bytes alone:

10:
((()()()()()){})

26:
((((()()()){}){}()){})

32:
((((()()()()){}){}){})

64:
(((((()()()()){}){}){}){})

This is horrible. So here's how we make it more convenient. The obvious approach is to push a 32 onto the alternate stack, which makes our 32 snippet become: (<>({})<>) and our 64 snippet become (<>({})({})<>). If we combine our initial push 32 with our initial push 26, we can save 8 bytes roughly. (my first golf).

But here is where the trick I'm really proud of comes in. Since we're not using the alternate stack for anything else, we might as well golf down the 10 also. To do this, we'll push 4 arbitrary numbers onto the stack right at the start of the program. Since we also push 32, this increases the value of the [] nilad, to 5, which makes our 10 snippet much more convenient. And lucky for us, it actually lets us golf the push 32 and 26 snippet down too!

#Push 32, 26
(((((()()()()){}){}){})<>[(()()()){}])

#Push 10
((()()()()()){})

Becomes

#Push 32, 26 (-2 bytes)
(((((())))))((([][][]){}()())[[]]<>)

#Push 10 (-6 bytes)
(<>[][]<>)

So here is a detailed explanation:

# Push 1 four times
((((()))))

# Push 32 to main stack (to reuse later)...
((([][][]){}()())

# And then 26 to the alternate stack
[[]()]<>)

#While true
{

    # Keep track of the current TOS
    (({})<

        # Push [TOS, TOS + 64] (To get uppercase characters)
        (({})<({}<>({})({})<>)>)

        # TOS times...
        {
            # Decrement the loop counter, while pushing a space underneath it
            ({}<(<>({})<>)>[()])

        # Endwhile, pop zeroed counter
        }{}

        # Push 10 (newline)
        (<>[][]<>)

    # Push TOS - 1 back one
    >[()])

# Endwhile
}

James

Posted 2017-06-08T01:35:23.157

Reputation: 54 537

7

V, 15 13 11 bytes

¬azòÙr klDj

Try it online!

Explanation

¬az         ' Insert a-z
   ò        ' Recursively
    Ù       ' Duplicate current line down
     r      ' Replace the first character with a ' '
       kl   ' Move up a line and right
         D  ' Delete from here to the end
          j ' Move back down

nmjcman101

Posted 2017-06-08T01:35:23.157

Reputation: 3 274

7

APL (Dyalog), 9 7 bytesSBCS

-2 bytes thanks to ngn's hint.

↑⍨∘-⌸⎕A

[Try it online!][TIO-j3o0ipjy]

⎕A the uppercase Alphabet

 between each (element,list of indices) pair, insert the following tacit function:

↑⍨ from the element (the letter) take…

 the…

- negated-index number of characters, i.e. that many characters from the back, padding on the front with spaces.

Try it online!

Adám

Posted 2017-06-08T01:35:23.157

Reputation: 37 779

Nice. My J attempt was quite a bit more verbose. Is there a translation of these verbs into J? – Jonah – 2017-06-08T07:27:02.847

@Jonah Verbs: is {. and is i. Adverbs: ¨ is "0 and is ~. – Adám – 2017-06-08T08:28:03.363

Thanks. Looks like the J translation loses some brevity: (a.{~97+i.26){."0~-1+i.26 – Jonah – 2017-06-08T15:08:17.223

@Adám the output doesn't look as required; hint: use to output a proper matrix and save 2 bytes – ngn – 2018-02-26T21:41:23.437

@ngn You may also return (…) a list of strings. But I'll investigate. Edit: Oh yes, of course! – Adám – 2018-02-26T21:43:21.317

@Adám grr, I should read more carefully, the challenge says "If you print this, it must appear like the above." and then contradicts itself – ngn – 2018-02-26T21:51:19.320

7

Google Sheets, 67 65 bytes

=ArrayFormula(IF(ROW(A1:Z)=COLUMN(A1:Z26),CHAR(96+ROW(A1:Z26)),))

=ArrayFormula(IF(ROW(A1:Z)=COLUMN(A1:Z26),CHAR(96+ROW(A1:Z26)),""))

Going off the clarification that any whitespace will do, I've used visibly empty cells

Output

Let me know if this doesn't count, if I've misunderstood the byte count or if I've screwed up some etiquette as this is my first post here.

Edit: It turns out I can save 2 bytes by leaving out the "" as Google sheets will accept an empty if value.

Mr.Parivir

Posted 2017-06-08T01:35:23.157

Reputation: 71

1Welcome to PPCG :) Looks good! Good job beating the other Google Sheets answer! – Stephen – 2017-06-09T15:45:05.053

6

Octave, 25 19 or 12? bytes

[diag(65:90)+32 '']

Try it online!

Other solution proposed by @LuisMendo (12 bytes) that I tested it in windows version of Octave:

diag('a':'z')

Explanation:

Generates diagonal matrix of a:z.

rahnema1

Posted 2017-06-08T01:35:23.157

Reputation: 5 435

@LuisMendo In tio I can not produce the same result. It is an expression ,that can be evaluated ,that produce the desired result:) – rahnema1 – 2017-06-08T09:46:57.357

The solution proposed by Luis seems to work on TIO now... New version of Octave maybe? – Stewie Griffin – 2018-06-01T21:08:44.060

Or new version of tio!? – rahnema1 – 2018-06-02T00:44:23.213

6

Java 8, 72 71 70 61 bytes

o->{for(int a=0;a++<26;)System.out.printf("%"+a+"c%n",a+96);}

-1 byte by outputting the uppercase alphabet instead of lowercase.
-1 byte by printing directly, instead of returning a multiline String.
-8 bytes thanks to @OliverGrégoire by using printf directly to get rid of String s="";. And also -1 byte by changing ()-> to o->.

Try it here.

Kevin Cruijssen

Posted 2017-06-08T01:35:23.157

Reputation: 67 575

The naive implementation is shorter than I would have thought. You can save a byte with c=65 (or 64 actually) so you don't need the 3 digit number. Can returning an array instead of the string save you any bytes as you can remove the +"\n"? – TheLethalCoder – 2017-06-08T08:37:23.357

@TheLethalCoder Ah, didn't knew we were allowed to output the uppercase alphabet. Skimmed over that. Thanks. And what do you mean by outputting an array? Like an array of arrays? – Kevin Cruijssen – 2017-06-08T08:42:21.453

Just an array of each line: or a list or strings. Although I'm not sure if it'll be any shorter. – TheLethalCoder – 2017-06-08T08:43:49.790

@TheLethalCoder Try defining an array, it's really long in Java: String s="",a[]=new String[26]. I wouldn't go that way. – Olivier Grégoire – 2017-06-08T08:44:57.930

@TheLethalCoder I doubt it will be shorter, because I'll have to initialize the array String[]a=new String[26]; or List import java.util.*;List l=new ArrayList();. I have been able to reduce it by an additional byte by printing directly instead of returning a multi-line String. – Kevin Cruijssen – 2017-06-08T08:45:37.393

@OlivierGrégoire, CC Kevin, I've not used Java so I wouldn't know just thought it was worth noting in case it helped. – TheLethalCoder – 2017-06-08T08:46:40.150

1@TheLethalCoder Any tip is welcome, so thanks. But in this case it won't be shorter. :) – Kevin Cruijssen – 2017-06-08T08:47:29.060

In that kind of answer, can you have a lambda parameter ? Having any dummy param would save 1 byte. Plus, can you pass the PrintStream as a parameter ? o->o.println("") It would actually make sense with the context, where do you want to print your diagonal. – Winter – 2017-06-10T00:39:15.030

1

@Winter About your first suggestion, that's still being discussed in this meta-post, but judging by the votes I guess it's indeed allowed from now on. As for the second I'm not sure.. It kinda feels like cheating/bending the rules, especially after these heated discussions in the comments of this meta post and answers.

– Kevin Cruijssen – 2017-06-10T10:12:58.823

1

62 bytes: ()->{for(int a=0;a++<26;)System.out.printf("%"+a+"c%n",a+96);} using the same idea as in another challenge.

– Olivier Grégoire – 2017-08-20T22:58:28.283

5

Jelly,  10  9 bytes

-1 byte thanks to Dennis (avoid decrementing J by using a lowered range, 26Ḷ, directly)

26Ḷ⁶ẋżØaY

A full program that prints the result.

Try it online!

(ØaJ’⁶ẋż for 7 is a monadic link that returns a list of lists of lists of characters, but that is like [["a"],[" ","b"],[" ","c"],...] which is probably unacceptable.)

I would, however, not be surprised if there was a shorter way I have not thought about!

How?

26Ḷ⁶ẋżØaY - Main link: no arguments
26        - literal 26
  Ḷ       - lowered range = [0,1,2,...,26]
   ⁶      - literal space character
    ẋ     - repeat          [ [],      [' '],      [' ',' '],    ...,  [' ',' ',...,' ']]
      Øa  - yield lowercase alphabet
     ż    - zip             [[[],'a'],[[' '],'b'],[[' ',' '],'c'],...,[[' ',' ',...,' '],'z']]
        Y - join with newlines  [[],'a','\n',[' '],'b',\n',[' ',' '],'c','\n',...,'\n',[' ',' ',...,' '],'z']
          - implicit print (smashes the above together, printing the desired output)

Jonathan Allan

Posted 2017-06-08T01:35:23.157

Reputation: 67 804

I'd even allow [["a"],[" ","b"],[" "," ","c"],...] since a list of chars is an alternative definition for a string, but a tuple doesn't seem to fit :) – Stephen – 2017-06-08T02:00:39.153

Yeah that's what I thought. – Jonathan Allan – 2017-06-08T02:01:20.057

1...note that in the above each "..." is a list of chars, so really it's [[['a']],[[[' '],['b']],[[' ',' '],['c']],...] since Jelly has no strings, just lists. – Jonathan Allan – 2017-06-08T02:14:02.490

26Ḷ⁶ẋżØaY saves a byte. – Dennis – 2017-06-08T02:33:04.133

ØaJ’⁶ẋż for 7, for your alternative version. – Leaky Nun – 2017-06-08T02:50:49.807

@Dennis Thanks - I do kind of think there must be a 6 or 7 byter out there... – Jonathan Allan – 2017-06-08T02:53:41.213

@LeakyNun, oh yeah LCC... – Jonathan Allan – 2017-06-08T02:55:30.483

5

PowerShell, 29 bytes

0..25|%{' '*$_+[char]($_+97)}

TessellatingHeckler

Posted 2017-06-08T01:35:23.157

Reputation: 2 412

I like how you add 97 to $_ as you go, nice. – root – 2018-02-26T21:14:40.547

5

Alice, 22 20 bytes

52E&waq'a+q&' d&o]k@

Try it online!

Even though the output is a string, it turns out ordinal mode is not the way to go for this challenge.

Explanation

52E&w             k@     do 26 times
     a                   push 10 (LF)
      q                  push current tape position (initially zero)
       'a+               add the ASCII code for "a"
          q&'            push 32 (space) a number of times equal to tape position
              d&o        output entire stack
                 ]       move tape position one space to the right

Previous solution

["za/?rO&
' !]\"ohkw@/

Try it online!

I went through about ten 23-byte solutions before I was able to find this one.

Explanation

This program uses the tape to track the number of spaces to output. Cardinal and ordinal modes use the same tape, but they have separate tape heads. The two modes have different interpretations of what they see on the tape, and the program fully exploits that difference.

The commands are executed in the following order:

[                   move cardinal tape position left
 "za"               push this string (as a string, since the final " is in ordinal mode)
     r              interpolate to entire range (i.e., the lowercase alphabet backward)
      h             split first character from string
       &            for each character in string: push that character and...
        w                                         push current address onto return address stack
         ' !        (cardinal mode) place 32 (space) at current cardinal tape position
            ]       (cardinal mode) move cardinal tape position right
             ?      (back to ordinal mode) read string from tape starting at ordinal tape position
                    this string will consist of n-1 spaces.
              o     output string of spaces
               O    output top of stack (current letter) followed by newline
                k   return to pushed return address. 
                    after 26 times through this loop, the return address stack will be empty and this is a no-op.
                 @  terminate

Nitrodon

Posted 2017-06-08T01:35:23.157

Reputation: 9 181

5

Brainfuck, 103 bytes

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

Try it online!

The location of the variables is somehow improvable.

Explanation

>-<-----[[<+>->>+++>-<<<]>++]   Initializes the tape.
<<<<<<<<<[-]>[-]>>-             Resets variables that
                                need to be at 0.
[                               For loop (25 to 0).
 <[-]<<[>+>+<<-]>>[<<+>>-]      Copy the spaces count in
                                order to use it in a loop.
 <[>>>>.<<<<-]                  Prints the spaces.
                                Prints the character followed
 <+>>>>.+>>.<<<-                by a new line. Also decrements
                                the main loop counter.
]

6infinity8

Posted 2017-06-08T01:35:23.157

Reputation: 371

5

Google Sheets, 69 bytes

=ArrayFormula(JOIN("
",REPT(" ",ROW(A1:A26)-1)&CHAR(96+ROW(A1:A26))))

Nothing complicated here. The only trick is using ArrayFormula and ROW(A1:A26) to return 26 different values for the JOIN function. Output looks like this:

Output


I think Excel 2016 can do the same thing with TEXTJOIN but I can't enter array formulas in the online version and only have 2013 myself. The formula should be this:

=TEXTJOIN("
",FALSE,REPT(" ",ROW(A1:A26)-1)&CHAR(96+ROW(A1:A26)))

Entering it as an array formula (Ctrl+Shift+Enter) adds curly brackets { } on both sides, bringing it to 67 bytes. Anyone who can verify it works is welcome to use it as their own answer.

Engineer Toast

Posted 2017-06-08T01:35:23.157

Reputation: 5 769

5

Seed, 6014 bytes

I don't think this will win any awards, but just for fun, here's a solution in Seed.

86 11103250503694729158762257823050815521568836599011209889044745493166180250197633623839266491438081837290079379263402288506775397211362446108152606095635373134468715450376738199004596861532212810083090232034321755895588102701453625219810339758989366211308223221344886043229936009486687653111291562495367476364760255760906228050130847228170228716790260998430434027546345063918859356161024202180254514539438087787769611000320430464740566450402368450792375043801526494811596087812709169139468697779440918934518195843690439213251884693846598754642076364755341359062651237754916053099089619667382845958005035392458577634784453744876558142057256976895330859887974064083588368087014591508237946214519271550243549214199679364098489146944338807874570414584343165070707969101892779772740177526390597395955859236589308394889243501541206981604661264930842784772121710695027991351718061777696274815931123342985242351444203296855501870888626347939456384376808446806093364176576945969539054970975848477876079897476093353730443488664472826635815956526890935049081522728044807877072639829234224838977148057506785320443165975265560224605597481381188291535996775480326796788286452216432605854564432262547835415260058472165825285438444435690700488258778785613363062417500848996527077259315494936037544655054620369560227407957368700650031346856230643646273909094915618471799926504192999361174763592054723307855670381682927214117502862645460031555724588536036895597768493827964819026940533784490457441244859937078155137620826821294513857153097135094397278852300032685608169642137925241118197368192392427097109982751185030229544527638686131131545529690698706313745703838144933923021851042677941879847025167921010148923860660695145106913052517930707522151230705792709484338746351589089180137363986003757314611932324492978098101655359729841878862276799317010824753645947659706175083519817734448003718088115457982394423932136760435046136644679525408371158980833993157988971884061469882136904103033944270884697456159261033500286722891139158500027351042265757431184139617566089023339480051231776345929815102059539844917563709940188668873305602146506284075271989710388430531233185164106985265575418252638186398535149202928422854319253947591044830747981534342833040219194969504971457701296402664807369043224201667623773161453335066484102800249947322601702575025462427139266561015140950621152993027466758026351218924607290766894274223554418125824416921899080393405328694235821466034161071834073874727856768719898425047229002772806527172294625623026601313091815217479540688812203850300478145319935479599086534606210099372526810614742385909275512758349679098012967475393301857434507012875239092688018536028125644341148882858752275129016876257290205949225918496182271679312996010157634568807332616541938310641844258434083838017690572891417189135014450484203635258935943095637185443145042430274553211816422809756194554145177421779800554334935224073734034988935790096239926730047370699006392111034056662661567902477446646680125183082979598538506383502737734442490068661537425714549752783861222862366340979663873475326752237893690641570287341027097775099918958849864419430754493042534812120486345363285167685811903366691676146427476942948696624274431993989133835880516551024369474029197791751838810883302415448112237526350703063618171739262753474029252659418383385834751808940073804107171146665382663467460066719556797639176747423279761528061219482681051780434845070421974558638870988408449698678976622755518024906714421419806347234183574860655249471877105716127767795785164699804819127058322715857697491583787449703283625085118896433923054087238479453964363805045497229148813441732912067120594705269402106426011497763749556561398150139686331615167139081591537739333533146667211063179804707883556569241294269430626179579760506971066676011512530066694518309930078451295032445835025178124213221937594928472509588116557231122849491576207720183829735710200290762251904109318007206980645946249679357907549498615310165588678201768095297568708803842208357473777731751349499510116345704811971207818719582793964185192140178454948686109674659005978400204479072321714207828018696339659886683414074211823497880135255138161141724546221354224299071581607979907417508104234534779573666933024250229754952685174194168516481670999039048675109878524061868078078216337487277443941946961426121900907734301692962783139932352047932263834773963592317279425421954035566305805348109175553209815893678595198155962166838761859540063188209014774346841267440789072833797121217961797443744676162541668802226500817146368372390178287945076657776275930590173768326046610094573983886099504933977126798348879838826160714899283593774855907724617352862079916515034033299006419237012240730789008999523238851913897908225482003661109026061857228300111070725651744312468140016983078297938157227595743419983763920290850801438187869169473456288283458163865462359588316419331445070232596307970490434468929587726795603069137946085898481642595124580643542063564880389350236902538522311931690905858973696558714577085714396738993556273941292496636824719451697631982422926675238248502170501569627556395875619564600587531422890212003952929325067813498958390095519100963598626450443103780781917045489137526377521695121594716424797216910752252094749957224424042047863869830458287114846161217532552045343745235776511344577755412402833175338541217548987687334493461236111032661075185714361252784989689657180878190058132112701323898697673356854132286586129946906160482715702618768869398700713988301485421822519104930442450343377920756456344715552821899659777521739288202633751258303637433110490141551780764889912485271829265224821750882760152112536985349681370761157202793523201156381835717321637420939424473215237574260806475544972321933149796156065126465186203580256364372579422208318560608817806013462242728082475787319168695978160861791054731154820533251279706873332364894538291172324730671914083193733203570060223897442373172904974570329139578763294810924815364789498523721281918680145538278976651264

It translates to the following Befunge program:

vaa{       @>
v#      g02<v
>30g20g`   |
10g-:!v!: < >#<
v,:g02_40g,1- ^
>1+20p$91+, v

TehPers

Posted 2017-06-08T01:35:23.157

Reputation: 899

5

shortC, 33 bytes

AOI_=0;++_<27;R"%*c\n",_,_+96));}

Try it online!

Jonathan Frech

Posted 2017-06-08T01:35:23.157

Reputation: 6 681

4

R, 59 49 47 bytes

-10 bytes thanks to djhurio

-2 bytes thanks to Sven Hohenstein

write("diag<-"(matrix("",26,26),letters),"",26)

Prints to stdout. Outgolfed by user2390246

Try it online!

Giuseppe

Posted 2017-06-08T01:35:23.157

Reputation: 21 077

You can replace 26^2 with 676 to save a byte. – Doorknob – 2017-06-08T02:57:24.323

2m=matrix("",26,26);diag(m)=letters;write(m,'',26) (49 bytes) – djhurio – 2017-06-08T07:20:16.543

For the same amount of bytes, you can print the matrix using cat(m,fill=27) – JAD – 2017-06-08T07:56:54.577

1@djhurio "For the same amount of bytes" – JAD – 2017-06-08T10:21:00.430

thanks guys! I clearly don't do much with matrices in R, lol. – Giuseppe – 2017-06-08T13:24:17.590

47 bytes: write("diag<-"(matrix("",26,26),letters),"",26) – Sven Hohenstein – 2017-06-08T13:51:28.100

@SvenHohenstein I see that that works and I'll be sure to use it but why does it work..? – Giuseppe – 2017-06-08T14:34:24.850

1@Giuseppe The command "diag<-"(x, y) is similar to diag(x) <- y. The value is not assigned to a variable but returned. – Sven Hohenstein – 2017-06-08T14:46:29.013

@SvenHohenstein That is dark magic indeed! – user2390246 – 2017-06-08T15:00:01.203

@SvenHohenstein I was more wondering why R interprets "diag<-"() as a function call. is it just the parentheses? Guess I still have a lot to learn. (It also works with diag<- in backquotes rather than quotes but that still doesn't answer my question) – Giuseppe – 2017-06-08T15:23:33.493

@Giuseppe Yes, it is because of the parentheses. Without them, "diag<-" is just a string. – Sven Hohenstein – 2017-06-08T17:55:44.320

4

><>, 46 44 42 bytes

"A"0::?!v" "o1-40.
*(?!;30.>~$:oao1+$1+:d2

Try it online!

Explanation

Line 1:
"a"0::?!v" "o1-40.
"a"0                       :Initialize the stack items (print char and space count)
    ::?!v                  :Duplicate the space count, check if 0, go down if 0
         " "o1-            :Print a space then take 1 from the space count
               40.         :Jump to codepoint row 0 col 4 (this restarts the loop)
Line 2:
*(?!;30.>~$:oao1+$1+:d2
        >~                 :Remove the zeroed space counter off the stack
          $:oao1+          :Place our print char on the top of the stack, duplicate and print it, print a new line, increase it by 1; a->b->c etc
                 $1+       :Place our space count on the top of the stack and increase it by 1
*                   :d2    :Duplicate the space counter, add 26 to the stack
 (?!;                      :Add 0 to the stack, less than compare 0, if the counter is above 0 it terminates
     30.                   :Jump to the first line, (back to printing spaces)

This is a completely different take from my previous 46 bytes so I've included the TIO to the only one as well. 46 bytes Try it online!

Below is a link to Emigna's submissions, it was the first ><> answer but I believe mine is different enough (and saves a few bytes) to warrant a second one.

Emigna's answer

Teal pelican

Posted 2017-06-08T01:35:23.157

Reputation: 1 338

And now we're tied. Best if you golf off a byte or two to be sure ;) – Emigna – 2017-06-08T13:12:37.517

@Emigna, I thought 3 saved bytes would be enough :o guess I have some more work to do :) – Teal pelican – 2017-06-08T13:31:11.183

4

Add++, 1069 bytes

+97
&
-87
&
+22
&
+66
&
-88
&
+22
&
&
+67
&
-89
&
+22
&
&
&
+68
&
-90
&
+22
&
&
&
&
+69
&
-91
&
+22
&
&
&
&
&
+70
&
-92
&
+22
&
&
&
&
&
&
+71
&
-93
&
+22
&
&
&
&
&
&
&
+72
&
-94
&
+22
&
&
&
&
&
&
&
&
+73
&
-95
&
+22
&
&
&
&
&
&
&
&
&
+74
&
-96
&
+22
&
&
&
&
&
&
&
&
&
&
+75
&
-97
&
+22
&
&
&
&
&
&
&
&
&
&
&
+76
&
-98
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
+77
&
-99
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
+78
&
-100
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+79
&
-101
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+80
&
-102
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+81
&
-103
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+82
&
-104
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+83
&
-105
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+84
&
-106
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+85
&
-107
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+86
&
-108
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+87
&
-109
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+88
&
-110
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+89
&
-111
&
+22
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
+90
&
P

Try it online!

Yep. That is hardcoded. I'm sure there is a better way, and if you want to find it, go ahead, but this way seems to work the best as Add++ is difficult to work with memory.

caird coinheringaahing

Posted 2017-06-08T01:35:23.157

Reputation: 13 702

4

Haskell, 66 65 58 57 45 43 bytes

Thanks to @nimi and @maple_shaft for saving 12 14 bytes.

unlines[(' '<$['b'..n])++[n]|n<-['a'..'z']]

Try it online!

vroomfondel

Posted 2017-06-08T01:35:23.157

Reputation: 2 094

1You would get the same score but sometimes you can use <$ instead of replicate: (' '<$[1..(fromEnum n-97)]) – maple_shaft – 2017-06-08T17:02:11.723

2You can change @maple_shaft's suggestion to (' '<$['b'..n]). – nimi – 2017-06-08T17:36:26.083

As unnamed functions are allowed, there's no need for the f=. – nimi – 2017-06-08T17:52:04.720

2Btw, same byte count: ['a'..'z']>>= \n->(' '<$['b'..n])++[n,'\n']. – nimi – 2017-06-08T17:59:18.877

4

PHP, 23 bytes

Note: uses IBM-850 encoding.

<?=join(~¶,range(a,z));

Run like this:

echo '<?=join(~¶,range(a,z));' | php -n;echo
# With default (utf8) terminal:
echo '<?=join("\v",range(a,z));' | php -n;echo

Explanation

Create an array of all characters of the alphabet, join it with a vertical tab as glue.

aross

Posted 2017-06-08T01:35:23.157

Reputation: 1 583

4

VBA, 35 Bytes

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

For i=0To 25:?Spc(i)Chr(97+i):Next

-2 Bytes thanks to @Chronocidal


Alternatively, 76 50 46 Bytes

Anonymous VBE immediate window function that takes no input and outputs the alphabet, diagonally, to the range [A1:Z26] on the VBE immediate window function

[A:Z]="=If(Row()=Column(),Char(64+ROW()),"""")

Taylor Scott

Posted 2017-06-08T01:35:23.157

Reputation: 6 709

You can save 3 bytes by changing Space(i);Chr(97+i) to Spc(i)Chr(97+i) – Chronocidal – 2018-03-09T17:30:43.943

1@Chronocidal - you are absolutely correct - this answer dates back to when I was having some issues with spc() vs space() - Did you know that Space(n) can be assigned to a variable while Spc() cannot? – Taylor Scott – 2018-03-09T19:18:26.247

Oh and @Chronocidal you seem to do a lot of work with VBA, so if you haven't already, you might want to check out the Tips for golfing in VBA page.

– Taylor Scott – 2018-03-09T19:21:43.400

4

brainfuck, 80 bytes

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

Try it online!

Formatted:

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

Uses a simple multiplicative generation function to put some constants in memory, then repeats the process of printing N spaces then 'A' + N for N = 0..25.

Annotated:

INITIALIZE TAPE: 10 32 65 >26< 0 0
C_NEWLINE: 10
C_SPACE: 32
V_ALPHA: 65
V_COUNTER: 26
V_PREFIX: 0
V_PREFIX_TEMP: 0
++++++++[>+>++++>++++++++>+++<<<<-]>++>>+>++

WHILE V_COUNTER != 0  [-
   "PRINT C_SPACE REPEATED V_PREFIX TIMES"
   "V_PREFIX_TEMP = V_PREFIX"
     V_PREFIX TIMES  >[-
       PRINT C_SPACE <<<.>>>
       INCREMENT V_PREFIX_TEMP >+<
     ]
   "V_PREFIX = V_PREFIX_TEMP PLUS 1"
     V_PREFIX_TEMP PLUS 1 TIMES  >+[-
       INCREMENT V_PREFIX <+>
     ]
   PRINT C_ALPHA <<<.
   INCREMENT C_ALPHA +
   PRINT C_NEWLINE <<.
>>>]

Conor O'Brien

Posted 2017-06-08T01:35:23.157

Reputation: 36 228

4

RProgN 2, 5 bytes

aS`\x0B.

\x0B is a Vertical Tab Literal

This just takes the lowercase alphabet, splits it, and joins it with vertical tabs. This produces the intended effect on certain Bash Terminals.

Running the script

ATaco

Posted 2017-06-08T01:35:23.157

Reputation: 7 898

4

Gforth, 45 Bytes

: X CR 26 0 DO i SPACES i 97 + EMIT CR LOOP ;

Explanation

Gforth doesn't allow interpretation of loops, so I had to define a new word X.

: X                 \ Define new word X
   CR               \ Go to a new line
   26 0 DO          \ Loop from 0 to 25
   i SPACES         \ Print i spaces
   i 97 + EMIT      \ Calculate ASCII-code and print it
   CR               \ Next line
;                   \ End of word definition

Try it online!

Kitana

Posted 2017-06-08T01:35:23.157

Reputation: 171

1Welcome to PPCG! – Martin Ender – 2018-04-17T20:09:26.717

4

Kotlin, 36 35 bytes

Saved a byte by removing comma (lambda outside of call.)

{List(26){" ".repeat(it)+('a'+it)}}

Try it online!

JohnWells

Posted 2017-06-08T01:35:23.157

Reputation: 611

3

Python 2, 42 bytes

Out-golfed... by Dennis, no less... ><

lambda:[' '*n+chr(n+65)for n in range(26)]

Try it online!

totallyhuman

Posted 2017-06-08T01:35:23.157

Reputation: 15 378

Any reason why you chose uppercase over lowercase? – Leaky Nun – 2017-06-08T02:54:35.080

1@LeakyNun First number I tried and I had to leave. – totallyhuman – 2017-06-08T09:55:38.913

3

Brachylog, 17 bytes

25⟦{;Ṣj₍}ᵐ;Ạzcᵐẉᵐ

Try it online!

Leaky Nun

Posted 2017-06-08T01:35:23.157

Reputation: 45 011

3

Brachylog, 16 bytes

Ạ;I∋₎C∧Ṣ;Ij₎wCẉ⊥

Try it online!

Explanation

Ạ;I∋₎C             C is the Ith character of "abcdefghijklmnopqrstuvwxyz"
      ∧Ṣ;Ij₎       Juxtapose " " I times
            w      Write to STDOUT
             Cẉ    Writeln C to STDOUT
               ⊥   False: try another C

Fatalize

Posted 2017-06-08T01:35:23.157

Reputation: 32 976

3

J, 28 bytes

([,{&a.@+&97@#)@#&' '"0 i.26

pretty:

([ , {&a. @ +&97 @ #) @ #&' ' "0 i.26

Jonah

Posted 2017-06-08T01:35:23.157

Reputation: 8 729

2

Welcome on the site! While there is no obligations to do so, feel free to add some explanations and maybe a link to an online interpreter where we can test your answer (like Tryitonline for instance).

– Dada – 2017-06-08T08:03:43.093

You can save a byte by using "+i.26 instead of "0 i.26 – Conor O'Brien – 2017-09-07T23:01:59.937

3

C#, 82 bytes

using System.Linq;()=>Enumerable.Range(0,26).Select(i=>"".PadLeft(i)+(char)(i+65))

Works by creating an array of ints from 0 - 25, creates a string of i length of only spaces. Then adds a char onto the end corresponding to an upper case letter. It lastly implicitly returns an array, in this case an IEnumerable<string>, of each line.

TheLethalCoder

Posted 2017-06-08T01:35:23.157

Reputation: 6 930

3

><>, 50 49 46 45 38 bytes

0>:5d*+oao:64*)?;1+:191.
?v84*o:{1+:}(

Try it online!

Explanation

0>          # initialize outer counter and start outer loop
:5d*+oao    # add outer counter to 65 and print as ascii followed by a newline
64*)?;      # if outer counter is greater than 24, end program
1+:1        # increment outer counter and initialize inner counter
91.         # jump to inner loop
:}(?v       # if inner counter is greater than outer counter go back to outer loop
84*o        # else print a space character
:{1+        # and increment inner counter

Emigna

Posted 2017-06-08T01:35:23.157

Reputation: 50 798

Your TIO link has an extra > command on the first line but also having a quick look; move the . on the second line to the end and you can then remove the space on the last line for -1 byte :) – Teal pelican – 2017-06-08T13:35:28.877

@Tealpelican: Thanks for the suggestion. I did some other changes that saved a byte, but I will check if your suggestion might have saved me more :) – Emigna – 2017-06-08T13:40:43.520

3

Perl 5 + -l, 21 bytes

$\.=$",print for a..z

Try it online!

Dom Hastings

Posted 2017-06-08T01:35:23.157

Reputation: 16 415

3

MATL, 5 bytes

2Y2Xd

Try it online!

Explanation

2Y2    % Predefined literal: 'a':'z'
Xd     % Diagonal matrix. Implicit display

Luis Mendo

Posted 2017-06-08T01:35:23.157

Reputation: 87 464

3

R, 40 bytes

write(c("",LETTERS)[diag(1:26)+1],"",26)

Try it online

                    diag(1:26)+1           # Create a matrix of ones with 2:27 on the diagonal
      c("",LETTERS)                        # Create a vector containing an empty string followed by the alphabet
      c("",LETTERS)[diag(1:26)+1]          # Use that vector as a lookup table for the matrix
write(                           ,"",26)   # Print over 26 columns

Use of write() copied from @Giuseppe's answer, but uses a different approach to creating the matrix.

Outgolfed by Sven Hohenstein

user2390246

Posted 2017-06-08T01:35:23.157

Reputation: 1 391

3

q/kdb+, 26 22 bytes

Solution:

-1(!:[26]#'" "),'.Q.a;

Example:

q)-1(!:[26]#'" "),'.Q.a;
a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
                q
                 r
                  s
                   t
                    u
                     v
                      w
                       x
                        y
                         z

Explanation:

Joins each letter of the alphabet with an increasing number of spaces. Brackets are used due to right-to-left evaluation.

-1(til[26]#'" "),'.Q.a; / ungolfed solution
-1                    ; / print to stdout and swallow return value
                  .Q.a  / shorthand for abc..xyz
                ,'      / concatenate (,) each-left/each-right (')
  (            )        / do all this together
          #'" "         / take each-left/each-right (space)
   til[26]              / range of 0..25

streetster

Posted 2017-06-08T01:35:23.157

Reputation: 3 635

3

Go, 97 bytes

package main;import."strings";func main(){for i:=0;i<26;i++{println(Repeat(" ",i)+string(i+97))}}

Definitely not the best language to golf with but wanted to get my first solution up, also should note this prints to stderr but I assume that's okay if it's not specificed

Go (as far as I know) lacks the ability to specify a dynamic width for padding formatted strings which is why I had to bring in and use strings.Repeat()

Readable version:

package main

import . "strings"

func main() {
    for i := 0; i < 26; i++ {
        println(Repeat(" ", i) + string(i+97))
    }
}

smt

Posted 2017-06-08T01:35:23.157

Reputation: 31

Welcome to PPCG! Yup, STDERR is OK. Nice first post, I'm out of upvotes for the day :/ – Stephen – 2017-06-08T15:37:21.067

No problem, thanks for the welcome @StephenS :) - I don't know if this is the best place to ask but I was looking on tryitonline and people seem to use the header/footer parts for stuff like imports, is that valid for all/most submissions? would probably save me a lot of bytes on Go stuff – smt – 2017-06-08T19:18:54.027

uhhh I don't know, try asking on meta, sorry – Stephen – 2017-06-08T19:22:12.777

3

Ohm, 10 bytes

αß:^MüL;_,

Try it online!

Explanation

αß:^MüL;_,  
αß          # Pushes [a-z]
  :         # For each...
   ^MüL;    # Print index amout of spaces
        _,  # Prints the char

Datboi

Posted 2017-06-08T01:35:23.157

Reputation: 1 213

4

I think this is the wrong challenge :) did you mean this one? https://codegolf.stackexchange.com/questions/125104/cartesian-product-of-two-lists

– Stephen – 2017-06-08T23:06:46.527

Yep you're right xD. Probably had the wrong tab open – Datboi – 2017-06-09T16:37:25.637

Updated the code to something that actually does this challenge – Datboi – 2017-06-09T16:50:19.303

3

Python 3, 41 bytes

for n in range(26):print(" "*n+chr(n+97))

Harry Wilkins

Posted 2017-06-08T01:35:23.157

Reputation: 51

You can save 2 bytes by using Python 2 – Beefster – 2018-04-17T17:56:12.453

3

Perl: 23 bytes

22 + 1 for -E flag.

say$"x$i++,$_ for a..z

Usage:

perl -E 'say$"x$i++,$_ for a..z'

Toto

Posted 2017-06-08T01:35:23.157

Reputation: 909

3

k, 21 bytes

`0:`c$32+(65+!26)*=26

Try it online.

Explanation:

                  =26 /identity matrix of length 26
         (65+!26)*    /for i in {0..25}:
                      /    matrix[i] *= 65 + i
      32+             /add 32 to everything
                      /    turns 0's into spaces
                      /    brings us to a lowercase alphabet for the rest
   `c$                /turn to characters
`0:                   /write to stdout/stderr

zgrep

Posted 2017-06-08T01:35:23.157

Reputation: 1 291

3

Common Lisp, 58 bytes

(dotimes(i 26)(format t"~v@a~%"(1+ i)(code-char(+ i 97))))

Try it online!

Renzo

Posted 2017-06-08T01:35:23.157

Reputation: 2 260

3

Yabasic, 49 bytes

Another answer which takes no input and outputs to the console.

For i=0To 25
For j=1To i?" ";Next
?Chr$(65+i)Next

Try it online!

Taylor Scott

Posted 2017-06-08T01:35:23.157

Reputation: 6 709

3

SmileBASIC 3, 33 bytes

FOR I=0TO 25?" "*I+CHR$(97+I)NEXT

Looks like 12Me hasn't answered this one yet…

snail_

Posted 2017-06-08T01:35:23.157

Reputation: 1 982

3

Assembly (nasm, x64, Linux), 62 59 55 45 + 8 bytes

func:
  ; R8 is the buffer the function will write the output to.
  ; most GPRs must be 0'd!
  mov al, 'a'
  inc edx
  or r8, buf ; Suprise! It's more efficient to write it this way, the equivilent mov requires 3 bytes of padding to follow.
.append:
  mov byte [r8+rbx], al
  mov byte [r8+rbx+1], 0Ah
  add ebx, 2
  cmp al, 'z'
  je .exit
  inc eax
  mov ecx, edx
  inc edx
.dospaces:
  mov byte [r8+rbx], ' '
  inc ebx
  ; cx is used here. Be aware!
  loop .dospaces
  jmp .append
.exit:
  ret

Try it online!

I spent a fair while doing this one. Seriously, some things will slowly drive you insane. This function outputs a buffer containing the requested data. Said buffer is in the .bss section.

NOTE: It doesn't seem to work on TIO for some reason. Works perfectly fine on my laptop. I built it using the following commands:

nasm -felf64 diagonal-alphabet_125117.s
gcc diagonal-alphabet_125117.o -no-pie 

For your viewing pleasure, the TIO version is modified to use the data section instead, so it actually runs.

The bytecount is currently based on the bytecount of the function and the 8 bytes needed to represent the length of .bss

Note to future readers: A CC where most GPRs must be 0'd can be useful, because or is shorter than mov, at least in the case demonstrated above.

moonheart08

Posted 2017-06-08T01:35:23.157

Reputation: 693

3

Underload, 104 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)(
)(:S( )*~S):*::*:*::***^

Try it online!

The snippet :S( )*~S has the meaning:

  • Duplicate and print the TOS
  • Add a space to the TOS
  • Print the string under the TOS

If the TOS starts as a newline and the strings on the stack form the alphabet (with a highest), then executing this snippet 26 times generates the correct output.

Esolanging Fruit

Posted 2017-06-08T01:35:23.157

Reputation: 13 542

3

Kotlin, 39 bytes

{('a'..'z').map{" ".repeat(it-'a')+it}}

Lambda returning a list of lines.

Try it online!

{                                  // lambda; implicitly return
    ('a'..'z').map {               // map over the lowercase alphabet
        " ".repeat(it - 'a')       // repeat space by letter position
                             + it  // append letter
    }
}

snail_

Posted 2017-06-08T01:35:23.157

Reputation: 1 982

3

MathGolf, 10 7 bytes

▄{ï *▌p

Try it online!

I'm happy to announce that MathGolf now has a 1-byte literal for the lowercase alphabet! That should make any challenge related to the alphabet a lot easier!

Explanation

▄         Push alphabet as string
 {        For-each
  ï *     Push " "*(loop counter)
     ▌    Prepend to the character
      p   Print

maxb

Posted 2017-06-08T01:35:23.157

Reputation: 5 754

3

PowerShell, 29 26 bytes

'a'..'z'|%{' '*($_-97)+$_}

Try it online!

Output:

a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
                q
                 r
                  s
                   t
                    u
                     v
                      w
                       x
                        y
                         z

KGlasier

Posted 2017-06-08T01:35:23.157

Reputation: 211

Welcome! There is the more correct answer - https://codegolf.stackexchange.com/a/125139/80745

– mazzy – 2018-11-21T20:54:00.283

@mazzy Thanks for letting me know. I tried to look through and find one but must've missed it! However I don't believe it's more correct. Same length, they just used lowercase, which case was said doesn't matter. Could you explain? Thanks! – KGlasier – 2018-11-21T21:00:29.647

1You are right, I wasn't precise enough. That solution is closer to the task definition. It is matter if lengths are equals. – mazzy – 2018-11-21T21:09:13.870

1@mazzy How about this one? I think I won now :P – KGlasier – 2018-11-22T22:34:02.200

Cool! It would be good to point out Powershell 6+ – mazzy – 2018-11-23T05:43:02.710

2

Pyth, 9 8 bytes

.e+*dkbG

Try it online

Explanation

.e     G  For each element of 'abc...z'...
   *dk    Take a string of spaces with length equal to the index...
  +   b   Add the letter.

user48543

Posted 2017-06-08T01:35:23.157

Reputation:

0 indexing really helps for this, doesn't it? – Stephen – 2017-06-08T02:02:16.750

I'm two months late, but you can take out the j because outputting as a list is allowed. – clap – 2017-07-25T08:28:37.393

@clap Improvements are always welcome. – None – 2017-07-25T13:02:16.717

2

Japt, 10 9 bytes

Saved 1 byte thanks to @Shaggy

;C£RiXiYî

Run it online!

Explanation:

;C£RiXiYî
;C          // Lowercase alphabet
  £         // Map; At each char:
   R        //   Newline
    iX      //   Insert: X (Iterative char)
      iYî   //   Insert: " " repeated Y (index) times

By default, i inserts the target char at index 0. So, RiXiYî becomes Yî +X+R.

Oliver

Posted 2017-06-08T01:35:23.157

Reputation: 7 160

;C£RiXiYî for 9 bytes. – Shaggy – 2017-06-08T06:52:46.410

;C¬£XiYç with -R also works for 9. – Shaggy – 2017-06-08T07:11:40.123

A short cut for would allow for an 8 byte solution ;) – Shaggy – 2017-06-08T13:58:02.390

2

QBIC, 27 bytes

[26|?space$(a-1)+chr$(a+96)

Explanation

[26|          FOR a = 1 to 26
?space$(a-1)  PRINT a-1 spaces (SPACES$ is a QBasic function that prints x spaces)
+chr$(a+96)      and a char representation of a+96

steenbergh

Posted 2017-06-08T01:35:23.157

Reputation: 7 772

2

Tcl, 52 bytes

set i 96;time {puts [format %[incr j]c [incr i]]} 26

time is really a tool for measuring time spent, but it's also handy for repetition of code. Indentation and letter are advanced in each iteration. Ascii code i needs preset to one-before-first-letter, j will be auto-set to 1 on first incr.

If run in an interactive tclsh, the time would also output timings, but if the line is in a script, then it's silent, except for the diagonal.

avl42

Posted 2017-06-08T01:35:23.157

Reputation: 111

2

ZX Spectrum BASIC, 29 bytes

FOR i=NOT PI TO VAL "25": LPRINT TAB i;CHR$ (i+VAL "97"): NEXT i

Numeric literals carry a 6-byte penalty, so using VAL saves me 3 bytes (VAL is a 1-byte token). Note: The ZX Spectrum's output area is only 22 lines high, so I'm sending the output to the printer instead.

Neil

Posted 2017-06-08T01:35:23.157

Reputation: 95 035

2

Scala, 41 bytes

('a'to'z').map(a=>println(" "*(a-'a')+a))

Previous answer: 45 bytes

(0 to 25).map(a=>printf("%s%c\n"," "*a,97+a))

It is 1 byte shorter than

(0 to 25).map(a=>println(" "*a+(97+a).toChar))

Try it online!

Aria Ax

Posted 2017-06-08T01:35:23.157

Reputation: 321

1Here is a 37 bytes solution: 'a'to'z'map(c=>println(" "*(c-97)+c)) – 6infinity8 – 2018-11-04T14:29:26.523

2

Bash, 38 36 35 bytes

printf "%*s
" `echo $[++i]\ {a..z}`

Try it online!

2 bytes less thanks to @DigitalTrauma

1 byte less thanks to @NahuelFouilleul

"%*s\n" takes padding as an argument. $((++i))\ {a..z} for each letter increment and prepend i plus space (arithmetic expansion)

marcosm

Posted 2017-06-08T01:35:23.157

Reputation: 986

1Replace $(( )) with $[ ]. – Digital Trauma – 2017-06-08T15:04:52.217

If another user suggests an edit that improves your score and you use it, it is usual to credit that user in your answer - Thanks! – Digital Trauma – 2017-06-11T18:30:06.143

I don't know if newline is counted as two characters or one, in that case \n can be replaced with new line – Nahuel Fouilleul – 2017-06-12T13:15:09.313

2

Nano, 186 77 bytes

M- represents the alt key

M-ia
 b
 c
 d
 e
 f 
 g
 h
 i
 j
 k
 l
 m
 n
 o
 p
 q
 r
 s
 t
 u
 v
 w
 x
 y
 z

Explanation

I've seen a few Vim answers on this site so I thought I would do a nano answer. Its not nearly as terse as the Vim answers but its still better than typing out the whole thing.

This is pretty simple (a lot simpler than my original answer). M-i sets the auto-indent on. This means that every line will copy the indentation of the last. So we start with a and every line add a space and a letter all the way through.

Post Rock Garf Hunter

Posted 2017-06-08T01:35:23.157

Reputation: 55 382

2

T-SQL, 63 bytes

DECLARE @ INT=0a:PRINT SPACE(@)+CHAR(@+65)SET @+=1IF @<26GOTO a

Written more conventionally, that would be:

DECLARE @ INT=0
a:
    PRINT SPACE(@) + CHAR(@+65)
    SET @ += 1
IF @<26 GOTO a

Tested and working on SQL Server 2012.

BradC

Posted 2017-06-08T01:35:23.157

Reputation: 6 099

2

Mathematica, 39 Bytes

Grid@DiagonalMatrix@Alphabet[]/. 0->" "

This has trailing whitespace.

Explanation:

                    Alphabet[]          - Create a list of the alphabet
     DiagonalMatrix@                    - Use that as the diagonal of a matrix
                              /. 0->" " - Replaces the 0's with whitespace
Grid@                                   - Then turn it into a 2D grid

Ian Miller

Posted 2017-06-08T01:35:23.157

Reputation: 727

Since a list of strings is allowed, and you are not asked to print it or anything, I don't think you need the Grid@. – Mark S. – 2017-08-19T16:13:41.087

2

TI-Basic, 71 69 bytes

"       
For(I,1,26
Disp sub(Ans+Ans+Ans+Ans,1,I)+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",I,1
End

Timtech

Posted 2017-06-08T01:35:23.157

Reputation: 12 038

Don't know how I missed that, thanks for -26 bytes @StephenS – Timtech – 2017-06-08T15:50:48.337

I think you can just do sub(Ans+Ans+Ans+Ans,1,I). – lirtosiast – 2017-08-25T00:43:26.457

@lirtosiast Thanks, I should have noticed that one. – Timtech – 2017-08-25T02:19:14.280

2

braingasm, 20 bytes

26[#[32.]97+#+.10.>]

26 times, print (.) a space (32) # (current position on the tape) times; increase cell (+) by 97, then by #; and print the current cell value, along with a newline (10); then go to next cell (>).

daniero

Posted 2017-06-08T01:35:23.157

Reputation: 17 193

2

JAVASCRIPT

Option 1: 59 bytes

a='';for(i=0;i<26;)a+=''.padEnd(i++)+(i+9).toString(36)+`
`

Option 2: 60 bytes

a='';for(i=0;i<26;)a+=' '.repeat(i++)+(i+9).toString(36)+`
`

Option 3: 61 bytes

a='',i=0;while(i<26)a+=' '.repeat(i++)+(i+9).toString(36)+`
`

Option 4: 67 bytes

a='';for(i=0;i<26;)a+=' '.repeat(i++)+String.fromCharCode(96+i)+`
`

Option 5: 68 bytes

[...Array(26)].map(_=>' '.repeat(++i-10)+i.toString(36),i=9).join`
`

w3jimmy

Posted 2017-06-08T01:35:23.157

Reputation: 121

easily tested in the browser's console :) – w3jimmy – 2017-06-08T20:00:45.400

2

Perl 6, 25 bytes

{" " «x«^26 Z~'a'..'z'}

This function returns a list of the required strings: "a", " b", " c", ...

^26 is a list of the numbers from 0 to 25. «x« is the string-replication hyperoperator that maps each element n of its right-hand side to the left-hand side replicated n times, producing the list "", " ", " ", .... That list is then zipped with string concatenation (the Z~ operator) with the range of letters from 'a' to 'z'.

Sean

Posted 2017-06-08T01:35:23.157

Reputation: 4 136

2

R, 56 bytes

for(i in 1:26){cat(rep(" ",i-1),LETTERS[i],'\n',sep='')}

Try it online!

Prints i-1 spaces and the ith letter of the alphabet, plus a newline, 26 times.

Outgolfed by Giuseppe (47 bytes), user2390246 (40 bytes), and Sven Hohenstein (37 bytes), but this is the only answer (so far) that doesn't use diag.

BLT

Posted 2017-06-08T01:35:23.157

Reputation: 931

2

Julia, 42 bytes

for i=0:25 println(" "^i,Char[97+i][1])end

Pretty straight forward, print space and character.

Try it online!

Goysa

Posted 2017-06-08T01:35:23.157

Reputation: 91

2

Ruby, 18 bytes

puts [*?a..?z]*?\v

Does not work on TIO, link for reference:

Try it online!

G B

Posted 2017-06-08T01:35:23.157

Reputation: 11 099

2

Pyth, 11 bytes

j.b+*dNY26G

Explanation:

Try it online!

j.b+*dNY26G   expects no input

j             joins on new line
 .b           for...in loop, uses two iterator variables
   +          joins *dN and Y
    *dN       repeats d (space) N times, where N is one of .b's iterating variables
       Y      another one of .b's iterating variables
        26    the array being iterated for N,.b automatically takes the unary range
          G   initialized to the lowercase alphabet, the array being iterated for Y

chromaticiT

Posted 2017-06-08T01:35:23.157

Reputation: 211

2

SOGL V0.12, 2 bytes

z╝

Try it Here!

z   push the alphabet
 ╝  convert to a diagonal array
    implicitly output as a newline joined string

dzaima

Posted 2017-06-08T01:35:23.157

Reputation: 19 048

2

Pyth, 13 bytes

I've noticed that I've been getting better at these, but Dave or Mr. Xcoder will school me any day of the week.

Update: Pyth tester is down, rip back up.

#p*dt=hZhG=tG

Explanation:

#         Loop until error
 p*dt=hZ  Print without newline: " " times ++Z - 1 (Z defaults to 0) (Could have used + instead of p, but it's easier to explain)
 hG       Implicit print with newline: The first character of the alphabet
 =tG      Remove the first letter in the alphabet variable

Try it online!

Stan Strum

Posted 2017-06-08T01:35:23.157

Reputation: 436

2

Befunge-98 (PyFunge), 30 bytes

1+:0\:'`+\' \k:>:#,_$:'␚-!k@a,

Where is a literal substitute character

Every line has 3 leading spaces

Try it online!

MildlyMilquetoast

Posted 2017-06-08T01:35:23.157

Reputation: 2 907

2

J, 19 16 bytes

u:32+(*=)65+i.26

Try it online!

FrownyFrog

Posted 2017-06-08T01:35:23.157

Reputation: 3 112

2

uBASIC, 36 bytes

Anonymous function that takes no input and outputs to the console.

0ForI=0To25:?Tab(I);Chr$(65+I):NextI

Try it online!

Taylor Scott

Posted 2017-06-08T01:35:23.157

Reputation: 6 709

1Soon: 100% of alphabet challenge are necromancer'd to the top being called "basic" xD. – Magic Octopus Urn – 2018-01-31T18:31:01.307

1@MagicOctopusUrn OH NO!!! You discovered my plot!! – Taylor Scott – 2018-01-31T18:36:30.940

1Creating meta-thread to vote on replacing tag "alphabet" with "basic" lmao! Seriously, I love these challenges, but there isn't an alphabet challenge not completed in 05AB1E... ;_; – Magic Octopus Urn – 2018-01-31T18:46:05.533

2

Pepe, 79 76 56 bytes

Way better, faster algorithm which performs like 3 times less operations. And saves 3 bytes. Now even more, because Pepe supports flags - no more unnecessary item movement!

REeEEEEeEErEeEEeeeeEREEreeereeErEEEEERrEeeEeeeeerEEEeRee

Try it online!

Explanation

REeEEEEeEE   # push "{" to R
rEeEEeeeeE   # push "a" to r

REE # label "{"

  reee # print stack contents
  reeE # print newline

  rEEEEE       # increment the letter
  R rEeeEeeeee # prepend a space
  rEEEe        # r pointer to end

Ree # goto "{" if the letter didn't reach "{" yet

RedClover

Posted 2017-06-08T01:35:23.157

Reputation: 719

2

PowerShell, 35 bytes

$i=97;0..25|%{" "*$_+[char]$i;$i++}

Try it online!

Pipes an array of 0 through 25 to ForEach-Object, which cycles through ascii codes and prefixes with a space multiplied by an incrementing variable.

root

Posted 2017-06-08T01:35:23.157

Reputation: 241

Roll the [char] calculation into the loop variable for 29 bytes -- Try it online!

– AdmBorkBork – 2018-03-19T13:25:58.040

2

Mouse-2002, 43 bytes

(A.Z1+<^A.B:(B.^" "B.1-B:)A.97+!'"!"A.1+A:)

Needs to be run in the Mouse-2002 Interpreter REPL. Working interpreter can be found here.

MooseOnTheRocks

Posted 2017-06-08T01:35:23.157

Reputation: 191

2

brainfuck, 64 bytes

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

Try it online!

Prints in uppercase with a trailing newline.

Initialises the tape to 2N, and uses the 16(-3) as the newline, the 32 as the space, the 64 as the start of the uppercase alphabet, the 128(+2) as the counter (-5 each loop), and the cell at the end as the space counter.

Jo King

Posted 2017-06-08T01:35:23.157

Reputation: 38 234

2

hakr14

Posted 2017-06-08T01:35:23.157

Reputation: 1 295

2

Stax, 6 bytesCP437

åuvÉ◄┘

Try it online!

Explanation

Uses the unpacked format to explain.

Vam]i^)
Va         "abcdefghijklmnopqrstuvwxyz"
  m        For each letter, execute the rest of the program
               Output the result on individual lines
   ]       Change the letter to a single-letter string
    i^     Current loop index+1
      )    Pad the string to given length

Weijun Zhou

Posted 2017-06-08T01:35:23.157

Reputation: 3 396

2

K4, 18 bytes

Solution:

-1(-1-!26)$'$.Q.a;

Example:

q)k)-1(-1-!26)$'$.Q.a;
a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
                q
                 r
                  s
                   t
                    u
                     v
                      w
                       x
                        y
                         z

Explanation:

Left-pad the alphabet:

-1(-1-!26)$'$.Q.a; / the solution
-1               ; / print to STDOUT, swallow return
             .Q.a  / "abcdefghijklmnopqrstuvwxyz"
            $      / string, basically 1#'
          $'       / pad ($) each-both
  (      )         / do together
      !26          / range 0..25
   -1-             / subtract from -1

Bonus:

15 bytes returning a list of strings rather than printing to STDOUT:

(-1-!26)$'$.Q.a

streetster

Posted 2017-06-08T01:35:23.157

Reputation: 3 635

2

QBasic 1.1, 35 bytes

FOR S=0TO 25
?SPC(S)CHR$(S+97)
NEXT

-8 thanks to DLosc.

Erik the Outgolfer

Posted 2017-06-08T01:35:23.157

Reputation: 38 134

2

Z80Golf, 19 bytes

00000000: c661 ff3e 0aff 3e20 0c41 ff10 fd79 fe1a  .a.>..> .A...y..
00000010: 20ee 76                                   .v

Try it online!

Disassembly:

restart:
  add 'a'
  rst $38
  ld a, '\n'
  rst $38
  ld a, ' '
  inc c
  ld b, c
k:rst $38
  djnz k
  ld a, c
  cp 26
  jr nz, restart
  halt

Lynn

Posted 2017-06-08T01:35:23.157

Reputation: 55 648

2

Pascal (FPC), 56 bytes

Well, I found 2 programs with the same number of bytes.

Program 1:

var c:char;begin for c:='a'to'z'do writeln(c:ord(c))end.

Try it online!

Explanation:

var c:char; //declare c as char variable
begin
  for c:='a' to 'z' do //iterate in a loop, c is getting values from a to z
    writeln(c          //write the current character followed by a newline
             :         //with a width of
              ord(c))  //ASCII code of the current character
                       //(using extraneous whitespace allowed by the challenge)
end.

Program 2:

var i:byte;begin for i:=97to 122do writeln(chr(i):i)end.

Try it online!

Explanation:

var i:byte; //declare i as integer variable in range 0..255
begin
  for i:=97 to 122 do //iterate in a loop, i starts from 97 and is incremented in each iteration
    writeln(chr(i)    //write character which ASCII codepoint is the current value of i
                  :   //with a width of
                   i) //current value of i
                      //(using extraneous whitespace allowed by the challenge)
end.

AlexRacer

Posted 2017-06-08T01:35:23.157

Reputation: 979

2

brainfuck, 74 bytes

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

Try it online!

Explanation

++++++++[->+++>+>++++++++>++++<<<<]>++>++ Initialize tape:
26(letter count) 10(lf) 64("A" minus 1) 32(" ") 0(space count) 0(temp) 

<[                                        for each letter count
  -                                       decrement letter count
  >>>>[-<.>>+<]                           for each space count print space and move value to temp
  +                                       increment space count
  >[-<+>]                                 add temp to space count
  <<<+.                                   increment and print letter
  <.                                      print lf
  <                                       go to count
]

Dorian

Posted 2017-06-08T01:35:23.157

Reputation: 1 521

2

C (gcc), 37 bytes

f(i){for(i=2912;i++%113;printf(&i));}

Inspired by @NieDzejkob; needs to be run on a little endian ASCII machine from a terminal supporting vertical tabs. Try it online!

ceilingcat

Posted 2017-06-08T01:35:23.157

Reputation: 5 503

1

Javascript, 75 72 bytes

_=>[...'abcdefghijklmnopqrstuvwxyz'].map((n,i)=>' '.repeat(i)+n).join`
`

3 bytes thanks to Stephen S.

Steve Bennett

Posted 2017-06-08T01:35:23.157

Reputation: 1 558

1

You can save some bytes with backticks and a literal newline for your join: https://jsfiddle.net/pL1onLqb/

– Stephen – 2017-06-08T02:21:48.530

Save a byte using some ES8: ''.padEnd(i)+n – Shaggy – 2017-06-08T07:08:43.217

1Also, outputting the array would seem to be permissible, in which case you can drop the join. – Shaggy – 2017-06-08T09:51:39.713

1

Cheddar, 31 bytes

->(|>26).map(n->' '*n+@"(n+97))

Try it online!

Defines a niladic lambda which returns a list of strings.

Full program, 42 bytes

print(|>26).map(n->' '*n+@"(n+97)).asLines

Try it online!

Leaky Nun

Posted 2017-06-08T01:35:23.157

Reputation: 45 011

1

Mathematica, 42 bytes

Table[" "~Table~i<>Alphabet[][[i]],{i,26}]

outputs a list of strings

J42161217

Posted 2017-06-08T01:35:23.157

Reputation: 15 931

A list of string format is allowed, so you don't need Column@, save 7 bytes. You can save another byte with " "~Table~i. Thanks for letting me know about Alphabet[]. – user202729 – 2017-06-08T14:38:55.980

I didn't notice it... thanks for -8bytes – J42161217 – 2017-06-08T14:52:30.023

1

Braingolf, 24 bytes

V# 7-#
R#a[R!&@# >1+v!@]

Try it online!

Explanation

V# 7-#\nR#a[R!&@# >1+v!@]
V                          Create stack2 and switch to it
 # 7-                      Push 32 and subtract 7
     #\n                   Push newline
        R                  Return to stack1
         #a                Push lowercase a
           [............]  Do-while loop, uses stack2 for loop counting
                           Will run 26 times
            R              Return to stack1
             !&@           Print entire stack without popping
                # >        Push space and move it to start of stack
                   1+      Increment letter
                     v     Switch to stack2
                      !@   Print newline

Skidsdev

Posted 2017-06-08T01:35:23.157

Reputation: 9 656

1

Noether, 52 bytes

"abcdefghijklmnopqrstuvwyxz"~aL(" "i*Pai/P"
"Pi1+~i)

Try it here!

Pushes the alphabet and loops through it, increasing the number of spaces before the character by one each time.


A non competing solution for 26 24 bytes is:

26(" "i*P0Ai/P"
"Pi1+~i)

Try it here!

Beta Decay

Posted 2017-06-08T01:35:23.157

Reputation: 21 478

1

Aceto, 28 bytes

L 'XcIo
p*=`MILp
aM{'&n
'@dL

Explanation:

First of all, we put the character a in our quick storage ('aM) and set a catch point (@). We then duplicate the top stack element (initially a zero) and load both from quick storage and from the character literal {. These characters are then tested for equality, in which case we exit (=`X).

Otherwise we push a space and multiply it with the previously duplicated stack element (used as a counter). This is then printed, which prints nothing the first time this is run, a single space the second time, and so on (' *p).

We load the current character again and print it, then we load it again, convert it to the number of its codepoint, increment it, convert it to a character again and memorize it (LpLoIcM). Finally, we increment our counter, print a newline, and jump to the catch mark (In&).

L3viathan

Posted 2017-06-08T01:35:23.157

Reputation: 3 151

1

S.I.L.O.S, 101 bytes

a=26
c=97
lblb
i=0
GOTO d
lblc
print  
b-1
i+1
lbld
if b c
b=i+1
printChar c
printLine
a-1
c+1
if a b

Try it online!

Leaky Nun

Posted 2017-06-08T01:35:23.157

Reputation: 45 011

1

LOGO, 47 bytes

Can be tried with FMSLogo. Unfortunately the version at Turtle Academy does not work well.

for[i 0 25][repeat :i[type "\ ]show char 65+:i]

user202729

Posted 2017-06-08T01:35:23.157

Reputation: 14 620

1

Oracle SQL, 62 bytes

SELECT LPAD(CHR(LEVEL+96),LEVEL) FROM DUAL CONNECT BY LEVEL<27

abrittaf

Posted 2017-06-08T01:35:23.157

Reputation: 119

1

AWK, 40 bytes

BEGIN{for(;++i<27;)printf"%"i"c\n",i+96}

Try it online!

I'm curious if there's a shorter way to do this in AWK.

Robert Benson

Posted 2017-06-08T01:35:23.157

Reputation: 1 339

not sure if the rules allow it, but replace BEGIN with END and add 1 char for the needed ctrl-d ? – Olivier Dulac – 2017-06-09T13:38:23.383

1

C# 73 68 bytes (Thanks to raznagul)

I'm pretty new to this. Do I need to include class/main declaration overhead for C#?

Edited to include anonymous function declaration

()=>{for(var x='a';x<123;)Console.WriteLine("".PadLeft(x-97)+x++);};

Broom

Posted 2017-06-08T01:35:23.157

Reputation: 211

Welcome to PPCG :) For this challenge (and most) you have two options. Either include the boilerplate (main et al) with what you are doing, or... you can create a function, and return either a list of strings for each row, or a string that, if you printed it, would display correctly. – Stephen – 2017-06-08T20:24:00.000

If you use upper case the while condition changes to x<91 saving 1 byte. And you can save another 2 bytes by removing the {} around the WriteLine-statement. – raznagul – 2017-06-09T09:27:46.630

I've found another 3 bytes that can be golfed away: 1) Use var instead of char. 2) In PadLeft write x-97. 3) Use for instead of while declaring x in the loop: for(var x='A';x<97;) – raznagul – 2017-06-09T09:44:36.397

thanks! I always thought I couldn't use var in a lambda. – Broom – 2017-06-09T13:45:18.140

1

Micro, 35 bytes

64:i {i1+:i i c:\
64 26+i=if(,a)}:a a

raddish0

Posted 2017-06-08T01:35:23.157

Reputation: 91

1

Pyke, 6 bytes

G Foh-

Try it here!

G      -  alphabet
  Foh- - for i in ^:
   oh  -   (o++)+1
     - -  i.pad(" ", ^)

Blue

Posted 2017-06-08T01:35:23.157

Reputation: 26 661

1

Pyke, 4 bytes

G\J

G   - alphabet
 \J - "\x0B".join(^)

Joins alphabet by vertical tabs

Blue

Posted 2017-06-08T01:35:23.157

Reputation: 26 661

1

SimpleTemplate, 66 42 bytes

This simply loops through all characters and outputs them one by one, with newlines and spaces.

{@forfrom"a"to"z"}{@echolV,_}{@setV V," "}

This abuses the automatic variable _ and the automatic flattening of echoed arrays and automatic newline with echol.

Ungolfed: (produces invalid results due to whitespace)

{@for chr from "a" to "z"}
    {@echo indentation, chr, "\n"}
    {@// will create an array like: [[[..., " "], " "], " "]}
    {@set indentation indentation, " "}
{@/}{@// automatically added after the code}


Old version:

There's a repeat function, but I couldn't use it because it's broken.
But this works too.

{@for_ from"a"to"z"}{@incz}{@callstr_repeat intos" ",z}{@echols,_}

Ungolfed: (produces incorrect results due to whitespace added)

{@set z 0}{@//removes warning}
{@for chr from "A" to "Z"}
    {@inc spaces by 1}
    {@call str_repeat into indentation " ", spaces}
    {@echo indentation, chr, "\n"}
{@/}{@// automatically added after the code}

Ismael Miguel

Posted 2017-06-08T01:35:23.157

Reputation: 6 797

1

Rexx (Regina), 41 37 bytes

do i=1 to 26
  say right(d2c(96+i),i)
end

Try it online!

theblitz

Posted 2017-06-08T01:35:23.157

Reputation: 1 201

1

Batch, 187 114 bytes

@set s=
@for %%p in (a b c d e f g h i j k l m n o p q r s t u v w x y z)do @call:e %%p
:e
@echo(%s%%1
@set s= %s%

stevefestl

Posted 2017-06-08T01:35:23.157

Reputation: 539

1You don't need the @s inside the ()s. Also, you don't need c at all - you can just add a space to s each time. By avoiding setlocal enabledelayedexpansion I got this down to 112 bytes. – Neil – 2017-06-12T15:33:08.253

I've successfully removed the @s, variable c, and now I couldn't figure out how to echo the variable s without delayedexpansion. – stevefestl – 2017-06-13T08:15:14.837

1Since you're so close already, here's my 112-byte solution: @set s=&for %%p in (a b c d e f g h i j k l m n o p q r s t u v w x y z)do @call echo %%s%%%%p&call set s= %%s%%. – Neil – 2017-06-13T12:13:33.863

1

Modern Pascal 2.0, 43 bytes

for var l:=97 to 122 do write(chr(l),#13);

Explanation For loop range is the ascii of 'a' to 'z', and the output is converting the ordinal to character, followed by LF (Line Feed, not CRLF), thus producing a forward diagonal alphabet. Also, Modern Pascal does not require the Begin/End block on simple instructions like this.

// Author of Modern Pascal

Ozz Nixon

Posted 2017-06-08T01:35:23.157

Reputation: 21

1

tcl, 54 47

time {puts [format %[incr i]c [expr $i+96]]} 26

demo

sergiol

Posted 2017-06-08T01:35:23.157

Reputation: 3 055

@avl42: mine is longer than yours :P – sergiol – 2017-06-12T17:09:38.880

@avl42: Mine is NOW shorter than yours, using your own poison! – sergiol – 2017-06-13T23:04:19.947

1

vim 14+16=30 keystrokes

16 keystrokes if you have alpha in nrformats already (I mean, who hasn't?), 30 otherwise.

:set nf=alpha<cr>
ia<esc>
qqYp<c-a>I <esc>q
24@q

Angle brackets denote single characters, e.g. <c-a> is ctrl+a (increment). Actual newlines only for clarity. Seriously, set nf+=alpha is really neat, and it's a feature I've missed in a few specific cases when programming.

algmyr

Posted 2017-06-08T01:35:23.157

Reputation: 858

1

Retina, 93 bytes


aAbBc¶3d¶4e¶5f¶6g¶7h¶8i¶9jA0kA1lA2mA3nA4oA5pA6qA7rA8sA9tB0uB1vB2wB3xB4yB5z
B
¶2
A
¶1
\d+
$* 

Try it online!

ovs

Posted 2017-06-08T01:35:23.157

Reputation: 21 408

1

C#, 82 bytes

var b="";for(int i=0;i<=25;i++){var a=(char)(97+i);b+=new string(' ',i)+a+"\r\n";}

Try it online!

Erlantz Calvo

Posted 2017-06-08T01:35:23.157

Reputation: 131

1

Swift 3, 75 bytes

for i in 0..<26{print(String(repeating:" ",count:i)+String(i+10,radix:36))}

Herman L

Posted 2017-06-08T01:35:23.157

Reputation: 3 611

1

Groovy, 40 38 bytes

i=0;("a".."z").each{println" "*++i+it}

Previous solution:

0.upto(25){println" "*it+("a".."z")[it]}

iis used to store the number of spaces that must be printed before each letter. The program iterates through the range "a".."z" (the alphabet), printing each letter with i spaces before it and increments i inline.

staticmethod

Posted 2017-06-08T01:35:23.157

Reputation: 191

1

Common Lisp, SBCL, 70 bytes

(dotimes(i 26)(format t"~v@t~a
"i(aref"abcdefghijklmnopqrstuvwxyz"i)))

Looping through letters of alphabet and outputting accurate number of spaces before each letter.

another 70 bytes solution:

(format t"~{~26<~a~#@t~>
~}"(coerce"abcdefghijklmnopqrstuvwxyz"'list))

looping through letters and justifying to 26 columns, where word to justify is letter+accurate number of spaces.

building alphabet list using code-char would make it 76 bytes:

(format t"~{~26<~a~#@t~>
~}"(loop as i from 97 to 122 collect(code-char i)))

user65167

Posted 2017-06-08T01:35:23.157

Reputation:

1

dc, 53 52 bytes

0si[32Plj1+dsjli>S]sS[0sjlid0<S1+dsi64+dPAP90>M]dsMx

Try it online!

Uppercase because checking that we're below character 90 (Z) is one fewer byte than checking that we're below character 122 (z). Otherwise pretty straightforward: one macro to print spaces and another to call the spacing macro, print the letter, and print a newline.

-1 byte because I forgot to golf my 10 into an A.

brhfl

Posted 2017-06-08T01:35:23.157

Reputation: 1 291

1

Pyth, 9 bytes

m+*;xGddG

Try it online!

The other Pyth approach is golfier because it uses enumerated map, which is 1 byte shorter. I just wanted to post a solution with regular map m, that happens to use the same variable, d as the built-in space. That may be inconvenient, because you cannot refer to the space with d. However, I did a work-around with ;, which gets the global value of the innermost lambda variable.

This returns a list of lines. In order to join them by newlines, we just need to add j in front of the whole code (the link contains the j for readability).

Explanation

jm+*;xGddG  - Full program.

 m       G  - Map over the alphabet with a variable d.
  +         - Add:
   *          - The multiplication of:
     xGd        - The index of the current letter in the alphabet (0-indexed) and
    ;           - Space (which is the global value of d, the innermost lambda 
variable).
        d     - The current letter.
j           - Optional: Join by newlines.

Mr. Xcoder

Posted 2017-06-08T01:35:23.157

Reputation: 39 774

1

QBasic, 54 bytes

SCREEN 12
FOR x=1TO 26
LOCATE x,x
?CHR$(x+96)
NEXT

Explanation

SCREEN 12       Set the screen mode to something that can actially handle > 20 chars on a line
FOR x=1TO 26    Loop from 1 to 26
LOCATE x,x      Set the cursior to the screen position x,x, starting at 1,1 on the top left.
?CHR$(x+96)  Print the current letter of the alphabet
NEXT

steenbergh

Posted 2017-06-08T01:35:23.157

Reputation: 7 772

1

C++ (gcc), 73 bytes

As unnamed generic lambda, requires a stream as parameter (like std::cout)

[](auto&O){for(char c=96;++c<123;O<<c<<'\n')for(char w=c-96;--w;O<<' ');}

Try it online!

Karl Napf

Posted 2017-06-08T01:35:23.157

Reputation: 4 131

1

Recursiva, 16 15 bytes

{)"P+*-O}97' '}

Try it online!

Explanation:

{)"P+*-O}97' '}
{                - For each
 )               - lower-case alphabet yield 'abc...z'
  "              - Iteration command begin
   P             - Print
    +            - concatenate
     *-O}97' '   - Appropriate number of spaces
              }  - current alphabet (iterate)          

officialaimm

Posted 2017-06-08T01:35:23.157

Reputation: 2 739

1

Pushy, 10 bytes

`a\x26`:"h32}

Where \x26 represents the literal byte 0x26.

Try it online!

`a\x26`         \ Push 'a' and 26
       :        \ Pop 26, loop that many times:
        "       \   Print the stack
         h      \   Increment the letter
          32}   \   Prepend a space

FlipTack

Posted 2017-06-08T01:35:23.157

Reputation: 13 242

1

AWK, 40 bytes

BEGIN{for(;i<26;)printf"%"++i"c\n",i+96}

Try it online!

I didn't see an AWK solution, so here we go. Straightforward implementation, so more golfing may be possible.

Robert Benson

Posted 2017-06-08T01:35:23.157

Reputation: 1 339

1

Sincalr ZX81/Timex TS1000/1500 BASIC, ~45 tokenized BASIC bytes

 1 FOR I=CODE "A" TO CODE "Z"
 2 PRINT TAB (I-CODE "A");CHR$ I
 3 NEXT I

Some notes; without adding in more bytes to the listing, the standard output to the screen is 32 x 22 only, so when the screen fills, you will need to press C, and the keyword CONT will appear. You will then see the rest of the alphabet.

For those who want to see the Alphabet without having to manually enter CONT each time the last row is hit in the text area, this solution does it for you:

 1 FOR I=CODE "A" TO CODE "Z"
 2 PRINT AT CODE "+",I-CODE "A";CHR$ I
 3 SCROLL
 4 NEXT I

This version costs another 9 tokenized bytes though.

Shaun Bebbers

Posted 2017-06-08T01:35:23.157

Reputation: 1 814

1

SNOBOL4 (CSNOBOL4), 72 65 bytes

E	&LCASE POS(X) LEN(1) . O @X	:F(END)
	OUTPUT =LPAD(O,X)	:(E)
END

Try it online!

swapping &UCASE for &LCASE would do the uppercase diagonal instead.

Giuseppe

Posted 2017-06-08T01:35:23.157

Reputation: 21 077

1

Pyth, 12 bytes

Fb26p*\ b@Gb

There's probably some way I can shave off a couple bytes, but I'm not quite sure yet.

Explanation:

Fb26p*\ b@Gb |
Fb26         | for b in range(26):
    p        |     print(
     *\ b    |           " "*b
         @Gb |                +G[b]

Note: G is initialized to "abcdefghijklmnopqrstuvwxyz"

ericeschnei

Posted 2017-06-08T01:35:23.157

Reputation: 71

1

MY-BASIC, 62 bytes

Anonymous function that takes no input and outputs to the console.

For i=0 To 25
For j=1 To i
Print" "
Next
Print Chr(65+I);
Next

Try it online!

Taylor Scott

Posted 2017-06-08T01:35:23.157

Reputation: 6 709

1

Visual Basic .NET (Mono), 98 bytes

Declared Subroutine that that takes no input and outputs to the console.

Module M
Sub Main
Dim I
For I=0To 25
Console.WriteLine(Space(i)+Chr(65+I))
Next
End Sub
End Module

Try it online!

Taylor Scott

Posted 2017-06-08T01:35:23.157

Reputation: 6 709

1

Momema, 51 bytes

m01*0w1-9 32 1+*1-1w0w=*1-9+97*0-9 10 0+1*0m=+-26*0

Try it online!

Explanation:

                                                              #  a = 0
m   0        #  label m0: jump past label m0 (no-op)          #  do {
1   *0       #            [1] = [0]                           #    b = a
w   1        #  label w0: jump past label w1                  #    while b != 0 {
-9  32       #            print chr 32                        #      print ' '
1   +*1-1    #            [1] = [1] - 1                       #      b -= 1
w   0        #  label w1: jump past label w0 (no-op)          #    [end-of-loop jump point]
w   =*1      #  label w2: jump past label w((2 + !![1]) % 3)  #    }
-9  +97*0    #            print chr 97 + [0]                  #    print chr(97 + a)
-9  10       #            print chr 10                        #    print '\n'
0   +1*0     #            [0] = [0] + 1                       #    a += 1
m   =+-26*0  #  label m1: jump past label m((1 + !![0]) % 2)  #  } while a != 0

Esolanging Fruit

Posted 2017-06-08T01:35:23.157

Reputation: 13 542

1

Python 3, 74 64 63 Bytes

Saved ten bytes thanks to Caird

Saved one byte thanks to Stephen

Changed format to one-liner

Yes there are several Python 2 answers but how about one with Python 3?

for b in'abcdefghijklmnopqrstuvwxyz':print(' '*(ord(b)-97)+b)

First it makes a list of the alphabet then prints each letter but with n (Index of the value) spaces.

Mercury Platinum

Posted 2017-06-08T01:35:23.157

Reputation: 161

164 bytes – caird coinheringaahing – 2018-02-26T21:12:52.523

41 bytes – Jo King – 2018-02-26T23:33:25.150

I found there's an identical answer here

– Jo King – 2018-02-26T23:54:35.693

Mine is a little different – Mercury Platinum – 2018-02-27T14:16:04.990

b in 'abc -> b in'abc – Stephen – 2018-02-28T01:52:39.437

1

Python 3, 51 bytes

print("\n".join(" "*n+chr(n+97)for n in range(26)))

The_Basset_Hound

Posted 2017-06-08T01:35:23.157

Reputation: 1 566

you can avoid the join stuff by putting all this in a comprehensive list [print(" "*n+chr(n+97))for n in range(26)] – bobrobbob – 2018-06-15T18:03:29.033

1

Japt -R, 7 bytes

;C¬ËiEç

Try it online!

Oliver

Posted 2017-06-08T01:35:23.157

Reputation: 7 160

1

PHP, 72 68 67 Bytes

Try it online!

Try it online (after @Titus review)

Try it online, last review. @Titus Strikes Back

Code, recursive function

function f($v=26){$v&&print str_pad("",$v).chr($v+96)." 
".f($v-1);}

Explanation

function f($v=26){
    $v&&print           # if $v not zero then print
    str_pad("",$v)     # pad spaces $v times
    .chr($v+96)     # concat the character at 96+$v 
    ."                 # concat a linebreak 
    ".f($v-1);          # call the function 
}

Francisco Hahn

Posted 2017-06-08T01:35:23.157

Reputation: 591

>

  • You need no braces for the echo. 2) Try $l&&print instead of if($l>0)echo. 3) And please don´t use $l as a variable name. ;)
  • < – Titus – 2018-06-17T21:26:08.083

    As always, thank you @Titus for your suggestions :D – Francisco Hahn – 2018-06-19T15:51:04.913

    You´re welcome. print needs no parentheses.

    – Titus – 2018-06-21T07:08:48.567

    1

    Java (OpenJDK 8), 58 bytes

    a->{for(char b=96;b++<122;a+=' ')System.out.println(a+b);}
    

    Try it online!

    I had no idea that you could make a for loop with a char variable... but here ya go! I’m pretty proud of my solution here, it may be my most golfed submission to date!

    X1M4L

    Posted 2017-06-08T01:35:23.157

    Reputation: 1 586

    1

    Add++, 43 36 bytes

    D,f,@:^,32$yVVL97+
    D,g,,26RBF€{f}
    $g
    

    Try it online!

    Super suboptimal because I don't know what I'm doing

    ASCII-only

    Posted 2017-06-08T01:35:23.157

    Reputation: 4 687

    1

    Python 2, 56 bytes

    a=map(chr,range(65,91))
    for i in a:print' '*a.index(i)+i
    

    Khalil

    Posted 2017-06-08T01:35:23.157

    Reputation: 49

    1

    CJam, 13 bytes

    26{_S*\'a+N}/
    

    Try it online!

    Explanation

    26{        }/  for i in [0..25]:
        S*           puts ' ' * i
       _  \'a+       puts 'a' + i
              N      puts '\n'
    

    Esolanging Fruit

    Posted 2017-06-08T01:35:23.157

    Reputation: 13 542

    1

    Ahead, 31 30 bytes

    "az"E>0\:'a-' l
      @?lj:oNW:k\<
    

    Try it online!

    -1 because leading spaces are allowed as long as everything is still aligned.

    snail_

    Posted 2017-06-08T01:35:23.157

    Reputation: 1 982

    1

    Ruby, 43 bytes

    (0..25).each{|n|print" "*n;puts (n+97).chr}
    

    Try it online!

    Alex Allen

    Posted 2017-06-08T01:35:23.157

    Reputation: 91

    1

    Perl 6, 24 bytes

    {map ' 'x$++~*,'a'..'z'}
    

    Try it online!

    Anonymous code block that returns a list of lines.

    Alternatively,

    {' 'x$++xx㉖Z~'a'..'z'}
    

    Try it online!

    behaves the same for the same bytecount.

    Jo King

    Posted 2017-06-08T01:35:23.157

    Reputation: 38 234

    1

    C# (.NET Core), 71 58 53 52 bytes

    for(var i='A';i<91;)WriteLine("".PadLeft(i-65)+i++);
    

    Try it online!

    Try it online!

    Try it online!

    Anth12

    Posted 2017-06-08T01:35:23.157

    Reputation: 111

    2Welcome to PPCG! :) – Shaggy – 2018-07-10T08:51:09.430

    1Suggest putting the i++ at the very end to save a byte. – Jonathan Frech – 2018-07-10T10:57:41.090

    Thanks @JonathanFrech I have included in my new approach – Anth12 – 2018-07-10T11:52:45.997

    1You can replace '[' with 91 for -1 byte – dzaima – 2018-07-10T23:45:53.370

    1

    dc, 28 bytes

    97[ddPAP1+2z8*B-^+z27>M]dsMx
    

    Try it online!

    Outputs to stdout, makes lowercase letters

    Explanation

    P pops a number from the stack and outputs it as a base-256 byte stream. So I use some math to calculate each number (representing the appropriate string) "inductively" from the previous.

    97        A literal, which P will print as ASCII 97 ('a')
    [         Each loop starts with these two things true:
                  The next number to Print is on top of the stack
                  The stack depth is the # of times the loop has started (inclusive)
      dd        Make two copies: one to manipulate stack depth, one to print
      PAP       Print the number, then Print a newline (0x0A)
      1+        Increment the last digit (i.e., the letter)
      2z8*B-^+  Add the leftmost space, calculated as: 
                     32*(256^loop counter)  (because 32 = ' ')
                   = 2^5*(2^8)^(z-2)        (z = stack depth = counter + 2)
                   = 2^(8z-11)              (and to dc, 'B' pushes literal 11)
      z27>M     Repeat unless this was our 26th time through
    ]dsMx       End the loop, store it as a macro, and run it
    

    Sophia Lechner

    Posted 2017-06-08T01:35:23.157

    Reputation: 1 200

    1

    ><>, 35 Bytes

    0::?\~1+:8c*+oao:55*)?;!
    -10.\84*o1
    

    Try it online

    0                         initialise counter
     :                        make a copy to count spaces
      :?\                     only keep looping if greater than 0
        \84*o                 output a space
    -        1                decrement the inner counter
     10.                      jump back to the start of the inner loop
         ~                    delete the inner loop counter
          1+                  increment the outer counter
            :8c*+o            make a copy of the counter, add 96, output the character
                  ao          output a newline
                    :55*)?;   terminate if the counter is now 26 or higher
                           !  skip the 0 at the start of the line
    

    Sasha

    Posted 2017-06-08T01:35:23.157

    Reputation: 431

    1

    Red, 37 bytes

    repeat n 26[print pad/left #"`"+ n n]
    

    Try it online!

    Galen Ivanov

    Posted 2017-06-08T01:35:23.157

    Reputation: 13 815

    1

    Dart, 65 bytes

    f()=>List.generate(26,(i)=>String.fromCharCode(i+65).padLeft(i));
    

    Try it online!

    Elcan

    Posted 2017-06-08T01:35:23.157

    Reputation: 913

    1

    C++ (gcc), 50 48 bytes

    [](){for(int c=0;printf("%*c\n",++c,c+97)-27;);}
    

    Try it online!

    ceilingcat

    Posted 2017-06-08T01:35:23.157

    Reputation: 5 503

    1

    MBASIC, 43 bytes

    1 FOR I=0 TO 25:PRINT SPC(I)CHR$(97+I):NEXT
    

    similar to Alphabet Staircase.

    wooshinyobject

    Posted 2017-06-08T01:35:23.157

    Reputation: 171

    1

    PowerShell Core, 27 bytes

    'a'..'z'|%{' '*(+$_-97)+$_}
    

    Try it online!

    Edwin

    Posted 2017-06-08T01:35:23.157

    Reputation: 71

    Hey Edwin, you can save an extra byte if you remove the + from the +$_-97 statement. Otherwise it's identical to my answer, see Here

    – KGlasier – 2018-12-04T18:42:34.387

    1

    Python 3 43 Bytes

    for i in range(26):print(" "*i+chr(i+97))
    

    CodeGolfer

    Posted 2017-06-08T01:35:23.157

    Reputation: 31

    1

    Aheui (esotope), 183 bytes (65 chars; 59 Hangul, 6 ASCII)

    발밦다빠따반두발따받타빠싺싻삮타빠바파자초
    분벋서썩떠번벌또여cbtp어또벓범석터번벋
    타타빠싹빠싺밨볺아멓히셕처오져퍼서써섟뻐서
    

    Try it online!


    "cbtp" in the middle of the code is just an abbreviation of my nickname, which is ignored by the interpreter and reduce 8 bytes by using ASCII, not Hangul.

    cobaltp

    Posted 2017-06-08T01:35:23.157

    Reputation: 401

    1

    Pushy, 10 bytes

    `a\0x1A;`:"32}h
    

    Where \0x1A is the character 26, 'SUB'

    Try it online!

    FlipTack

    Posted 2017-06-08T01:35:23.157

    Reputation: 13 242

    1

    Attache, 21 bytes

    Output[sp*0:25+$a:$z]
    

    Try it online!

    Explanation

    Output[sp*0:25+$a:$z]
    Output[             ]     write each entry as a line to stdout:
           sp*0:25                spaces repeated 0 to 25 times (array)
                  +$a:$z          each followed by a letter from "a" to "z"
    

    Alternatives

    22 bytes: Output[" "*0:25+$a:$z]

    23 bytes: Print=>(" "*0:25+$a:$z)

    24 bytes: Print@{_*sp+NTS@_}=>0:25

    31 bytes: Print@&PadLeft=>Zip[$a:$z,1:26]

    35 bytes: {Print@_If[$z!in_,$[sp+Succ@_]]}@$a

    37 bytes: {Print@_If[_@-1/=$z,$[sp+Succ@_]]}@$a

    37 bytes: Print@&PadLeft=>Zip[Chars@alpha,1:26]

    40 bytes: Output!ZipWith[PadLeft,Chars@alpha,1:26]

    40 bytes: Print=>ZipWith[PadLeft,Chars@alpha,1:26]

    Conor O'Brien

    Posted 2017-06-08T01:35:23.157

    Reputation: 36 228