# Diagonal Alphabet

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

## Canvas, 2 bytes

ｚ＼


Try it here!

# 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


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

-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  # Pepe, 7976 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  # QBasic 1.1, 35 bytes FOR S=0TO 25 ?SPC(S)CHR$(S+97)
NEXT


-8 thanks to DLosc.

# Z80Golf, 19 bytes

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


Try it online!

Disassembly:

restart:
rst $38 ld a, '\n' rst$38
ld a, ' '
inc c
ld b, c

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

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

# 05AB1E, 8 4 bytes

₂A3Λ


Try it online!

-4 bytes thanks to @ovs.

₂     # push 26
A    # push "abcdefghijklmnopqrstuvwxyz"
3   # push 3
Λ  # draw a line on an ASCII canvas that is 26 characters long, uses lowercase letters in order for characters, and goes in direction 3 (southeast)


# Python 3.8 (pre-release), 60 bytes

n=0
for l in"abcdefghijklmnopqrstuvwxyz":print(" "*n+l);n+=1


Try it online!

• This is shorter without an assignment expression: Try it online! Dec 9, 2021 at 15:05
• @pxeger Fixed.. Dec 9, 2021 at 15:07
• Actually, I was wrong; leading spaces are allowed. But it's still shorter this way. Dec 9, 2021 at 15:08

# JavaScript (Node.js), 63 bytes

for(i=0;++i<27;){console.log(" ".repeat(i)+(i+9).toString(36))}


Try it online!

# Vyxal, 15 14 bytes

₄ʁ(|kaniðn*p,)


Try it Online!

• 10 bytes Dec 30, 2023 at 17:55
• 6.125 bytes Dec 30, 2023 at 18:24

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

## Javascript, 75 72 bytes

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



3 bytes thanks to Stephen S.

• You can save some bytes with backticks and a literal newline for your join: jsfiddle.net/pL1onLqb Jun 8, 2017 at 2:21
• Save a byte using some ES8: ''.padEnd(i)+n Jun 8, 2017 at 7:08
• Also, outputting the array would seem to be permissible, in which case you can drop the join. Jun 8, 2017 at 9:51

# 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
#a                Push lowercase a
[............]  Do-while loop, uses stack2 for loop counting
Will run 26 times
!&@           Print entire stack without popping
# >        Push space and move it to start of stack
1+      Increment letter
v     Switch to stack2
!@   Print newline


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

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

# Mathematica, 42 bytes

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


outputs a list of strings

• 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[]. Jun 8, 2017 at 14:38
• I didn't notice it... thanks for -8bytes Jun 8, 2017 at 14:52

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


# Oracle SQL, 62 bytes

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


# Micro, 35 bytes

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


## Pyke, 6 bytes

G Foh-


Try it here!

G      -  alphabet
Foh- - for i in ^:
oh  -   (o++)+1


## Pyke, 4 bytes

G\J

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


Joins alphabet by vertical tabs

# 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++);};

• 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. Jun 8, 2017 at 20:24
• 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. Jun 9, 2017 at 9:27
• 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;) Jun 9, 2017 at 9:44
• thanks! I always thought I couldn't use var in a lambda. Jun 9, 2017 at 13:45

# 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