# Diagonal Alphabet

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!

• 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 Jun 8 '17 at 23:30
• @DigitalTrauma as long as it appears the same, I don't care what kind of whitespace you use. – Stephen Jun 8 '17 at 23:31
• Can I use tabs instead of spaces? – user69335 Jun 9 '17 at 23:28
• @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 Jun 9 '17 at 23:32
• does not affecting appearance include having an extra leading space or 2? – MildlyMilquetoast Sep 11 '17 at 17:08

# Charcoal, 2 bytes

↘β


Try it online!

### How?

 β - the lowercase alphabet
↘  - direction


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

• The right language :) – Stephen Jun 8 '17 at 1:44
• 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 Jun 8 '17 at 1:51
• 2 bytes?! In what encoding is the SOUTH EAST ARROW a single byte? – Wyck Jun 8 '17 at 13:00
• @Wyck Charcoal (note: speculation) uses a custom code page, which can be compressed to 1 byte instructions. That's legitimate for Code Golf. codegolf.meta.stackexchange.com/questions/9428/… – Draco18s no longer trusts SE Jun 8 '17 at 13:12
• @StephenS, I think you mean the bottom-right language :) – Wossname Jun 9 '17 at 21:29

## C, 45 bytes

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


Thanks to @Dennis for saving 5 bytes!

• Works on my machine™ – Destructible Lemon Jun 8 '17 at 2:08
• I think you'd have to initialize or reset i at some point. At least on TIO, f() only works once. – Dennis Jun 8 '17 at 2:37
• @Dennis Ah, you're right. Fixed that. – Doorknob Jun 8 '17 at 2:46
• f(i){for(i=0;++i<27;printf("%*c\n",i,i+96));} saves a few bytes. – Dennis Jun 8 '17 at 3:38
• f(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 Jan 15 '18 at 16:39

# 05AB1E, 148 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+ç«}»

• You can save another 2 bytes with AvyNú». – Emigna Jun 8 '17 at 6:09
• @Emigna: Thanks! Will edit that in. – Neil A. Jun 8 '17 at 6:37
• ƶ seems so perfect, but it's not :(. – Magic Octopus Urn Jun 8 '17 at 14:28
• Λ probably wasn't available yet at the time, but 26A3Λ saves a byte. – Kevin Cruijssen May 8 '18 at 8:35
• @MagicOctopusUrn ₂A3Λ would have been even shorter. – Kevin Cruijssen Aug 12 '18 at 14:45

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

• Whoa, 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 Jun 8 '17 at 2:22
• @SteveBennett Correct, but n.toString(++n)+f(n) is a byte shorter than n.toString(36)+f(n+1). – ETHproductions Jun 8 '17 at 2:27
• You could do f=(n=10,s='')=>n-36?s+n.toString(++n)+'\n'+f(n,s+' '):"" for 55. – Arnauld Jun 8 '17 at 6:39
• Save a byte with some ES8: "".padEnd(n-10)+n.toString(++n). – Shaggy Jun 8 '17 at 8:09
• @Arnauld, f=(n=10,s='')=>n-36?s+n.toString(++n)+'\n'+f(n,s+' '):s would seem to be permissible. – Shaggy Jun 8 '17 at 8:37

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

## R, 3837 36 bytes

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


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

• I 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 Jun 8 '17 at 13:56
• @user2390246 Thanks for pointing out! – Sven Hohenstein Jun 8 '17 at 14:13
• you can use 1 rather than "" to shave off another byte. – Giuseppe Apr 12 '18 at 23:22
• @Giuseppe Thanks for pointing out! – Sven Hohenstein Apr 13 '18 at 4:40

: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

• 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 Jun 8 '17 at 11:36
• Thanks @nmjcman101! I was trying to find some way to try vim online and never knew that about V – jmriego Jun 8 '17 at 12:26
• You can use ␛ instead of <Esc>. It looks a little better in my opinion. – Wheat Wizard Jun 8 '17 at 14:05
• You can save one byte if you do { instead of gg – James Jun 8 '17 at 21:24

# 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
after 26 times through this loop, the return address stack will be empty and this is a no-op.
@  terminate


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


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

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.

# 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+ :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 • And now we're tied. Best if you golf off a byte or two to be sure ;) – Emigna Jun 8 '17 at 13:12 • @Emigna, I thought 3 saved bytes would be enough :o guess I have some more work to do :) – Teal pelican Jun 8 '17 at 13:31 # 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!

• You would get the same score but sometimes you can use <$ instead of replicate: (' '<$[1..(fromEnum n-97)]) – maple_shaft Jun 8 '17 at 17:02
• You can change @maple_shaft's suggestion to (' '<$['b'..n]). – nimi Jun 8 '17 at 17:36 • As unnamed functions are allowed, there's no need for the f=. – nimi Jun 8 '17 at 17:52 • Btw, same byte count: ['a'..'z']>>= \n->(' '<$['b'..n])++[n,'\n']. – nimi Jun 8 '17 at 17:59

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

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


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