g | x | w | all
Bytes Lang Time Link
049AWK250905T164618Zxrs
015Pyth170819T021749ZStan Str
014MATL170819T124701ZSuever
057Python 3220602T050609ZSapherey
009Vyxal j220602T010840ZnaffetS
101Python 3211209T184232ZAlan Bag
053Forth gforth201110T152312ZRazetime
00905AB1E201110T150325ZKevin Cr
009Japt R201110T124756ZShaggy
056Python 2170819T020336ZThe Fift
107SNOBOL4 CSNOBOL4171219T144901ZGiuseppe
050Excel VBA170820T172501ZTaylor R
051VBA Excel171110T101729Zremoel
067PHP171110T071558ZJo.
145 Elixir171110T062253ZShashidh
068Retina170819T102003ZNeil
070SimpleTemplate170820T123707ZIsmael M
050Bash170823T202127ZJustin M
006Pyke170823T135331ZBlue
060PowerShell170821T134206ZAdmBorkB
048Röda170823T092957Zfergusq
036Perl 5170819T132519ZDom Hast
039Perl 5170819T040850ZXcali
011APL Dyalog170821T112314ZAdá
012Gaia170819T125109ZBusiness
098Java 1.8 without Lambda170819T142636ZDouglas
098Brainbash170821T112230ZConor O&
089R170820T171424ZSlowLori
069Java OpenJDK 8170820T224258ZOlivier
054Haskell170820T174822Znimi
031q/kdb+170819T180035Zmkst
009Charcoal170819T020748Znotjagan
043Ruby170819T022437Zm-chrzan
013Japt170819T020720ZETHprodu
512><> v170819T153302ZSasha
060Haskell170819T132852ZCristian
012Pyth170819T072133ZMr. Xcod
6618C# .NET Core170819T100916ZGrzegorz
040Proton170819T082251ZMr. Xcod
052Python170819T070025ZMr. Xcod
084Common Lisp170819T055130ZRenzo
01105AB1E170819T041655ZJustin M
050C gcc170819T050845ZJustin M
052Python 3170819T050637ZLeaky Nu
011Jelly170819T045550ZLeaky Nu
012SOGL V0.12170819T034524Zdzaima
052Python 2170819T030844Ztotallyh
067Mathematica170819T030012ZJungHwan
066JavaScript ES2017170819T021400ZETHprodu
072JavaScript Node.js170819T023729ZConor O&
103Mathematica170819T021424ZZaMoC
057Python 2170819T020636ZStephen

AWK, 49 bytes

{for(;i++<26;)printf"%"(i<$1?i:$1)"s%c\n",X,i+96}

Attempt This Online!

Pyth, 21 17 15 bytes

VlG+*d?>QNNQ@GN

Explanation:

VlG        For each character in the alphabet (G)
+          Concatenate...
 *d        Space (d) times...
   ?>QNNQ  Ternary; if Q (input) is less than N, return N, else Q
 @GN       The Nth character of the alphabet (G)

Try it online!

MATL, 14 bytes

26:tiXl2Y2oZ?c

Try it at MATL Online

Explanation

26      % number literal
:       % range; vector of equally spaced values [1...26]
t       % duplicate
i       % explicitly grab the input
Xl      % clamp the array to have a maximum value of the input
2Y2     % predefined literal: ['a'...'z']
o       % convert to a numeric array
Z?      % create sparse matrix using the first two inputs as the rows/columns 
        % and the letters 'a'...'z' as the values
c       % convert back to character and implicitly display

Python 3, 57 bytes

lambda n:[f"{chr(65+i):>{min(i+1,n)}}"for i in range(26)]

Try it online!

Used python formatting to automatically put spaces in output i.e. {'a':>5} will give a

Vyxal j, 9 bytes

ka¨2?‹∵Ip

Try it Online!

Python 3, 101 bytes

def f(n,a=0):
 b="abcdefghijklmnopqrstuvwxyz"
 for l in range(len(b)):print(" "*a,b[l]);a+=[0,1][l<n]

Try it online!

Forth (gforth), 53 bytes

: f 1- 26. do dup i min spaces i 97 + emit cr loop ; 

Try it online!

Pretty standard answer.

05AB1E, 9 bytes

27α‚A34SΛ

Try it online.

A golfed version of the existing 05AB1E answer in the new 05AB1E version is 9 bytes as well:

Av<N‚ßyú,

Try it online.

Explanation:

27α        # Take the absolute difference of 27 with the (implicit) input
   ‚       # Pair it to the (implicit) input
    A      # Push the lowercase alphabet
     34S   # Push 34 as a list of digits: [3,4]
        Λ  # Use the Canvas builtin with these three as arguments:
           #  Direction [3,4], which translates to [↘,↓]
           #  Characters to draw: the lowercase alphabet
           #  Length of each part to draw: [input,|input-27|]
           # (after which the result is output immediately afterwards)

See this 05AB1E tip of mine for an in-depth explanation of how the canvas builtin works.

A          # Push the lowercase alphabet
 v         # Pop and loop over each of its characters `y`:
  <        #  Decrease the (implicit) input by 1
   N‚      #  Pair it with the 0-based loop index
     ß     #  Pop and push the minimum of this pair
      y    #  Push the current character
       ú   #  Pop both, and pad the character with leading spaces equal to the integer
        ,  #  Pop and print this string with trailing newline

Japt -R, 9 bytes

;C¬ËùUm°E

Try it

;C¬ËùUm°E     :Implicit input of integer U
;C            :Lowercase alphabet
  ¬           :Split
   Ë          :Map each character at 0-based index E
    ù         :Left pad with spaces to length
     Um       :  Minimum of U and
       °E     :  E incremented
              :Implicit output joined with newlines

Python 2, 61 58 57 56 bytes

def f(i,j=0):exec"print(' '*~-i)[:j]+chr(97+j);j+=1;"*26

-3 bytes thanks to Rod

-2 more bytes thanks to Mr. Xcoder

SNOBOL4 (CSNOBOL4), 107 bytes

	N =INPUT
I	&LCASE POS(R) LEN(1) . L
	OUTPUT =DUPL(' ',X) L
	R =R + 1
	X =LT(R,N) X + 1
	LT(R,26)	:S(I)
END

Try it online!

Excel VBA, 53 50 Bytes

Anonymous VBE immediate window function that takes input of expected type Integer in the domain of [1,26] from range [A1] and outputs to the VBE immediate window

For i=0To 25:[B1]=i:?Spc([Min(1:1)])Chr(97+i):Next

VBA Excel, 51 bytes

using Immediate Window and [a1] as input

for x=1to 26:?spc(iif(x<[a1],x,[a1]))chr(96+x):next

PHP, 67 bytes

<?for($l=a;$l!=aa;)echo str_pad($l++,min($argv[1],++$x)," ",0)."
";

Try it online!

Elixir, 145 bytes

{n,_}=IO.gets("")|>Integer.parse;for x<-?a..?z,do: if x-97<n,do: IO.puts String.pad_leading(<<x>>,x-96),else: IO.puts String.pad_leading(<<x>>,n)

Try online

Retina, 72 68 bytes

^
z
{2=`
$`
}T`l`_l`^.
\D
$.`$* $&¶
\d+
$* 
s`( *)( +)(?=.*¶\1 $)
$1

Try it online! Output includes trailing whitespace. Save 1 byte by deleting the space before the $ if zero-indexing is allowed. Edit: Saved 4 bytes by using @MartinEnder's alphabet generator. Explanation:

^
z
{2=`
$`
}T`l`_l`^.

Insert the alphabet.

\D
$.`$* $&¶

Diagonalise it.

\d+
$* 

Convert the input to unary as spaces.

s`( *)( +)(?=.*¶\1 $)
$1

Trim overlong lines so that no line is longer than the blank line at the end.

SimpleTemplate, 79 70 bytes

The code outputs the required text and a trailing newline.

{@forfrom"a"to"z"}{@echols,_}{@inca}{@ifa is lowerargv.0}{@sets s," "}

Ungolfed:

{@for letter from "a" to "z"}
    {@echo spaces, letter, EOL} {@// same as echol}
    {@inc by 1 index} {@// sets to 1 if it doesn't exist}
    {@if index is lower than argv.0}
        {@// creates an array like [[[...], " "], " "]}
        {@set spaces spaces, " "}
    {@/} {@//not required}
{@/} {@// not required}

You can try it on http://sandbox.onlinephpfunctions.com/code/a0ee99464f463d23072ff5d5be7dbd3a532f9c7c

(Old version: http://sandbox.onlinephpfunctions.com/code/a60e11b9dd2dcd54a84c11937f1918f26e0adcfa)

Bash, 50 bytes

for c in {A..Z};{ printf "%$[++i<$1?i:$1]s\n" $c;}

Try it online!

Takes input as a command-line argument.

Pyke, 6 bytes

G\xb1oh->

Try it here!

          - o = 0
G         -  alphabet
 \xb1     - for i in ^: (1 byte, pretty prints)
     oh   -    (o++)+1
       -  -   " "*^ + i
        > -  ^[input:]

PowerShell, 66 60 bytes

param($a)65..90|%{" "*(($b=$_-65),($a-1))[$b-ge$a]+[char]$_}

Try it online!

Loops through the alphabet, each iteration using string multiplication to prepend the appropriate number of spaces (chosen using a pesudo-ternary (,)[]), then string-concatenates with the current character.

Röda, 48 bytes

f n{seq 1,26|min([n,_])<>chr 96+_1|print" "*_,_}

Try it online!

Each output line has one leading space.

Explanation:

f n{
  seq 1,26|    /* push numbers 1..26 to the stream (inclusive) */
               /* for each number in the stream: */
  min([n,_])<> /*  push min(n, _1) */
  chr 96+_1|   /*  push string containing _1 as a letter */
               /* for each number _1 and letter _2 in the stream: */
  print" "*_,_ /*  print _1 spaces and _2 */
}

Perl 5, 36 bytes

31 bytes code + 5 for -i# -l.

Note: this takes input via -i, if that is unacceptable (since it's non-standard) I can remove.

$\.=$"x(--$^I>0),print for a..z

Try it online!

Explanation

For this I'm abusing the special variable $\ which is automatically printed after each call to print, to store the next line's indentation. Using the flag -l (which enables line ending processing), $\ is pre-initialised to "\n" so we append a space each time we process an element in the range a..z, as long as --$^I isn't less than 0. Using $^I (via the -i commandline flag) means I don't need to store input separately, but it's bit of a stretch as its not the usual way to accept input in Perl. Since the postfix for loop stores the current item in $_, we don't need any arguments to print ($_ is automatically printed and $\ is automatically appended) so we just call it each iteration, appending spaces as we go to get the desired output. This does append trailing spaces though, which @SpookyGengar has allowed.

Thanks to @Xcali for pointing out an oversight!

Perl 5, 47 39 bytes

$l=<>;say$"x($#i+=$#i<$l-1).$_ for a..z

Try it online!

APL (Dyalog), 12 11 bytes

-1 as OP has now clarified that returning a list of strings is fine.

Prompts for input.

⎕A↑¨⍨-⎕⌊⍳26

Try it online!

⍳26 first 26 strictly positive ɩntegers

⎕⌊ minimum of input and those

- negate those

⎕A↑⍨¨ for each letter of the Alphabet, take that many characters (from the rear, as all numbers are negative), padding with spaces as necessary


 convert list of strings into matrix (only in TIO link to enable readable output)

Gaia, 12 bytes

…26⊃§×¦₵a+†ṣ

Try it online!

Explanation

…             Range 0..input-1
 26⊃          Repeat the last number enough times to make it have length 26
    §×¦       Turn each number into a string of that many spaces
       ₵a+†   Add the corresponding letter to each
           ṣ  Join with newlines

Java 1.8 (without Lambda), 98 Bytes

void m(int i){int c=0,o=97;String s="";for(;c++<26;s+=c<i?" ":"")System.out.println(s+(char)o++);}

The logic is straightforward. Provides no input data validation, very bad!

Brainbash, 98 bytes

+[-[---<]>>-]<-~++++++++[>++++>+++>+<<<-]>>++>++>#-<<[>>>[-<<<<.>>>>>+<]>[-<+>]<<{->+<}<<-~.+~>.<]

Try it online!

Explanation

The code can be split into two parts:

+[-[---<]>>-]<-~++++++++[>++++>+++>+<<<-]>>++>++>#
-<<[>>>[-<<<<.>>>>>+<]>[-<+>]<<{->+<}<<-~.+~>.<]

Basically, generate the constants 97, 32, and 26. Then, takes a number N as input. After input (#) the tape looks like:

[ ]   0      0     >97     0
[*]   0      32     26     10    >0

The second part executes 26 times, each time decrementing the input. Every time the input is decremented, the prefix length is incremented. After the input reaches zero, the prefix length remain constant. After each loop, the spaces, the letter, and a newline are printed.

R, 99 89 bytes

@MickeyT saved 10 bytes

function

function(x)for(i in 1:26)cat(paste(c(rep(" ",min(x,i)),letters[i]),collapse=""),sep="\n")

demo

f <- function(x)for(i in 1:26)cat(paste(c(rep(" ",min(x,i)),letters[i]),collapse=""),sep="\n")
f(1)
f(10)
f(15)
f(26)

Java (OpenJDK 8), 69 bytes

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

Try it online!

Haskell, 58 54 bytes

f n=do m<-[1..26];([2..min n m]>>" ")++['`'..]!!m:"\n"

Try it online!

How it works

f n=                  -- input number is n
  do m<-[1..26]       -- for each m from [1..26], construct a string and concatenate
                      -- them into a single string. The string is:
   [2..min n m]>>" "  -- min(n,m)-1 spaces,
      ++              -- followed by
   ['`'..]!!m         -- the m-th char after `
      :               -- followed by
   "\n"               -- a newline 

Edit: @Lynn saved 4 bytes. Thanks!

q/kdb+, 33 31 bytes

Solution:

-1{(&[x-1;til 26]#'" "),'.Q.a};

Example:

q)-1{(&[x-1;til 26]#'" "),'.Q.a}16;
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:

Create a list of spaces (26) up to the length of the minimum of the input and the range of 0..25), join with each letter of the alphabet, print to stdout.

-1{(&[x-1;til 26]#'" "),'.Q.a}; / solution
-1                            ; / print result to stdout and swallow return
  {                          }  / lambda function
                         .Q.a   / "abcd..xyz"
                       ,'       / concatenate (,) each
   (                  )         / do all this together
    &[   ;      ]               / minimum of each 
      x-1                       / implicit input (e.g. 10) minus 1 (e.g. 9)
          til 26                / 0 1 2 ... 23 24 25
                   '#" "        / take " " each number of times (0 1 2 )

Notes:

Charcoal, 9 bytes

↘✂β⁰N↓✂βη

Try it online!

How it works

↘✂β⁰N↓✂βη
 ✂β⁰N         the alphabet from position 0 to the input
↘               print diagonally, down and to the right
        ✂βη    the alphabet starting from the position of the input
       ↓        print downwards

This solution no longer works in the current version of Charcoal (most likely due to a bug fix), but the issue is resolved for 10 bytes with ↘✂β⁰N↓✂βIθ.

Ruby, 51 46 43 bytes

->n{(0..25).map{|x|(' '*x)[0,n-1]<<(x+97)}}

Returns a list of strings.

Looks like the Python guys were on to something with their subscripts. -5 bytes by taking inspiration from Mr. Xcoder's improvement of ppperry's solution.

Previous solution with rjust (51 bytes):

->n{i=0;(?a..?z).map{|c|c.rjust i+=n>c.ord-97?1:0}}

Japt, 16 13 bytes

Saved 3 bytes thanks to @Oliver

;C£RiXiYmUÉ î

Test it online!

><> (-v), 51+2 Bytes

'a'$1-0\   /' 'o1-81.
'z')?;}>::?/~$:@@:@)+{:oao1+:

Try it online

equivalent pseudo code

char = 'a'
input = read_number
input -= 1
tabCount = 0

while true
    for i from 0 to tabCount
        print ' '
    if tabCount < input
        ++tabCount
    print char
    print '\n'
    ++char
    if char > 'z'
        exit

Haskell, 60 bytes

f n=unlines$scanl(\p c->take(n-1)(p>>" ")++[c])"a"['b'..'z']

This is a function that returns the output as a String.

Try it online.

Pyth, 12 bytes

j.e+<*kdtQbG

Try it here!

If lists of Strings are allowed, this can be shortened to 11 bytes:

.e+<*kdtQbG

Pyth, 12 bytes

VG+<*dxGNtQN

Try it here!

Pyth, 14 bytes

jm+<*d;tQ@Gd26

Try it here.

If lists of Strings are allowed, this can be shortened to 13 bytes:

m+<*d;tQ@Gd26

How do these work?

Unlike most of the other answers, this maps / loops over the lowercase alphabet in all 3 solutions.

Explanation #1

j.e+<*kdtQbG - Full program.

 .e        G - Enumerated map over "abcdefghijklmnopqrstuvwxyz", with indexes k and values b.
     *kd     - Repeat a space a number of times equal to the letter's index.
    <   tQ   - Crop the spaces after the input.
   +      b  - Concatenate with the letter.
j            - (Optional): Join by newlines.

Explanation #2

VG+<*dxGNtQN  - Full program.

VG            - For N in "abcdefghijklmnopqrstuvwxyz".
      xGN     - Index of the letter in the alphabet.
    *d        - Repeat the space a number of times equal to the index above.
   <     tQ   - But crop anything higher than the input.
  +        N  - Append the letter (at the end)

Explanation #3

jm+<*d;tQ@Gd26 - Full program.

 m          26 - Map over [0...26) with a variable d.
    *d;        - Space repeated d times.
   <   tQ      - Crop anything whose length is higher than the input.
  +      @Gd   - Concatenate with the letter at that index in the alphabet.
j              - (Optional): Join by newlines.

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

n=>new int[26].Select((x,i)=>$"{(char)(i+97)}".PadLeft(i<n?i+1:n))

Byte count also includes

using System.Linq;

Try it online!

This returns a collection of strings, one for each line. If it's not allowed, the answer will swell by 17 bytes for string.Concat() and \n inside string

Explanation:

n =>
    new int[26]                      // Create a new collection of size 26
    .Select((x, i) =>                // Replace its members with:
        $"{(char)(i + 97)}"          // String of an alphabet character corresponding to the index
        .PadLeft(i < n ? i + 1 : n)  // Add spaces to the left
    )

Proton, 40 bytes

Assuming that a list of Strings is fine.

k=>[(i*" ")[to~-k]+chr(i+97)for i:0..26]

Try it online!

Proton, 49 bytes

As ASCII-art instead:

k=>'\n'.join((i*" ")[to~-k]+chr(i+97)for i:0..26)

Try it online!

Python, 52 bytes

Quite surprised nobody noticed the obvious approach was also as short as the others.

lambda k:[(i*" ")[:k-1]+chr(i+97)for i in range(26)]

Try it online!

Python, 53 bytes

lambda k:[min(k-1,i)*" "+chr(i+97)for i in range(26)]

Try it online!

Common Lisp, 84 bytes

(lambda(x)(dotimes(i 26)(format t"~v,,,@a~%"(if(< i x)(1+ i)x)(code-char(+ i 97)))))

Try it online!

05AB1E, 11 bytes

AvNI<‚Wysú,

First time trying 05AB1E, so I'm open to tips.

Try it online!

If a zero-indexed input from 0 to 25 is allowed, this can be 10 bytes by omitting the <.

C (gcc), 50 bytes

i;f(n){for(;i<26;printf("%*c\n",i++<n?i:n,i+97));}

Try it online!

Python 3, 52 bytes

lambda n:[('%*c'%(i,i+96))[-n:]for i in range(1,27)]

Try it online!

Jelly, 11 bytes

26Ḷ«’⁶ẋżØaY

Try it online!

SOGL V0.12, 12 bytes

z{ē.-.Hχ@*Ot

Try it Here!

Python 2, 52 bytes

lambda n:['%*c'%(min(i+1,n),i+97)for i in range(26)]

Try it online!

I'm assuming a list of strings is fine...

Shortest I could get with recursion:

f=lambda n,i=0:i<26and['%*c'%(min(i+1,n),i+97)]+f(n,i+1)or[]

Mathematica, 67 bytes

SparseArray[x=#;{#,#~Min~x}->Alphabet[][[#]]&~Array~26,{26,#}," "]&

Returns a SparseArray of strings. To visualize, append Grid@ in front.

Try it on Wolfram Sandbox

Usage

Grid@SparseArray[x=#;{#,#~Min~x}->Alphabet[][[#]]&~Array~26,{26,#}," "]&[5]
a
 b
  c
   d
    e
    f
    g
     
    ⋮
   
    z 

JavaScript (ES2017), 73 72 71 66 bytes

Saved some bytes thanks to @JustinMariner

f=(n,x=26)=>x?f(n,x-1)+(x+9).toString(36).padStart(x<n?x:n)+`
`:''

JavaScript (Node.js), 72 bytes

n=>[..."abcdefghijklmnopqrstuvwxyz"].map((e,i)=>" ".repeat(i<n?i:n-1)+e)

Returns a list of strings.

Try it online!

Mathematica, 103 bytes

(T=Table;a=Alphabet[];c=Column)[c/@{T[""<>{T[" ",i],a[[i]]},{i,#}],T[""<>{T[" ",#],a[[i]]},{i,#,26}]}]&

Python 2, 62 50 57 bytes

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

Try it online!

Steals heavily from this answer by Dennis.