# Draw an alphabet party hat

            z
yz
xyz
wxyz
vwxyz
uvwxyz
tuvwxyz
stuvwxyz
rstuvwxyz
qrstuvwxyz
pqrstuvwxyz
opqrstuvwxyz
nopqrstuvwxyz
mnopqrstuvwxyz
lmnopqrstuvwxyz
klmnopqrstuvwxyz
jklmnopqrstuvwxyz
ijklmnopqrstuvwxyz
hijklmnopqrstuvwxyz
ghijklmnopqrstuvwxyz
fghijklmnopqrstuvwxyz
efghijklmnopqrstuvwxyz
defghijklmnopqrstuvwxyz
cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz


Case does not matter.

Remember, this is , so the code with the smallest number of bytes wins.

• Why the downvotes? – Oliver Ni Oct 25 '16 at 23:31
• I suspect some people are just tired of all the alphabet-pattern ascii-art KC challenges. – xnor Oct 26 '16 at 0:21
• Can we do it in uppercase? – Downgoat Oct 26 '16 at 3:43
• Seriously though, another alphabet challenge? – Erik the Outgolfer Oct 26 '16 at 12:57
• I enjoy these alphabet challenges. This one could easily re-branded as a Christmas tree. – Pete Arden Nov 18 '16 at 21:49

# Cheddar, 504542 37 bytes

25|>0=>i->print" "*(i/2|0)+(65+i)@"90


Straightforward, but utilizes cheddar's consise ranging syntax (both numerical and alphabetical)

Try it online!

## Explanation

25 |> 0 =>    // Map range [0, 26) (i.e. [25, 0] reversed) over....
i ->
print    // Prints in it's own line...
" " * (i/2 |0) +     // Number of spaces is floor(n/2).
// |0 for flooring is hack from JS
(65 + i) @" 90       // Char code range is this


65 is char code for A and 90 for A

• Z is 90, not A. – Mego Oct 26 '16 at 4:37

# 05AB1E, 15 13 bytes

A.svy12N;ï-ú,


Try it online! (slightly different from above as ú isn't on TIO yet)

Explanation

1. Push alphabet
2. Compute the suffixes of the alphabet
3. Prepend 12-index/2 spaces
4. Print

# Python 2, 70 bytes

Ported from Emigna's answer, -2 bytes for replacing -i-1 with ~i

for i in range(26):print' '*(12-i/2)+"abcdefghijklmnopqrstuvwxyz"[~i:]

• I'm fairly sure using map can yield a shorter alphabet, except maybe lowercase having higher values – Destructible Lemon Oct 26 '16 at 3:25
• Actually I'm not sure anymore. I think it wouldn't work for this anyway :( soz – Destructible Lemon Oct 26 '16 at 3:34

# R, 67 66 59 bytes

EDIT: Saved a couple of bytes thanks to @rturnbull

for(i in 25:0)cat(rep(" ",i/2),letters[i:25+1],"\n",sep="")


Exploiting the fact that any number passed to the rep function is automatically rounded down to the closest integer (e.g. rep("*",1.99) => "*") which means that the actual sequence passed is floor(13-1:26/2):

12 12 11 11 10 10  9  9  8  8  7  7  6  6  5  5  4  4  3  3  2  2  1  1  0  0

• This comes out shorter than my matrix attempt. Replace 14...-1 with 13? – JDL Oct 26 '16 at 10:23
• @JDL Ah yes of course. A remnant of attempting another approach – Billywob Oct 26 '16 at 11:00
• If you loop through 25:0 instead of 1:26, you can change 13-i/2 to i/2, and simplify (27-i):26 to i:25+1, saving 6 bytes. – rturnbull Oct 26 '16 at 14:54

# Pyth, 15 bytes

j_m+*/d2\ >GdUG


A program that prints the result to STDOUT.

Try it online

How it works

j_m+*/d2\ >GdUG  Program
UG  Yield [1, 2, 3, 4, ..., 26]
m              Map over the range with variable d:
>Gd      Yield alphabet with first d-1 letters discarded
+               Prepend
/d2             d//2
*   \            spaces
_               Reverse
j                Join on newlines
Implicitly print

• Try ; instead of \  – isaacg Oct 26 '16 at 5:17

## Python 2, 52 bytes

n=26;s=''
while n:n-=1;s=chr(97+n)+s;print n/2*' '+s


Accumulates the string s to print and updates the number of leading spaces n/2. A while loop terminating at 0 is a rare numerical loop than beats an exec loop (53 bytes):

n=26;s=''
exec"n-=1;s=chr(97+n)+s;print n/2*' '+s;"*n


Also a 53-byte alternative:

s=''
exec"s=chr(122-len(s))+s;print s.center(26);"*26


# JavaScript (ES6), 857569 68 bytes

for(s=a='',x=36;--x>9;)s+= .repeat(x/2-5)+(a=x.toString(36)+a)+



-1 byte thanks to @l4m2.

• Isn't this a snippet rather than a function or program? – Neil Oct 27 '16 at 12:35
• for(s=a='',x=36;--x>9;)s+= .repeat(x/2-5)+(a=x.toString(36)+a)+'#' 1B shorter – l4m2 Jan 5 '18 at 11:38
• @l4m2 Brilliant! – darrylyeo Jan 7 '18 at 3:15
• Nice idea using base 36! +1 – Titus Apr 29 '18 at 15:38

# Brain-Flak, 244 bytes

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


Try it online!

This should be readable enough as is. If you need it, I have a full explanation:

push 122 (z): ((((((()()()()())){}{}){}){}()){})
push 26:      ((((()()()){}){}()){})
loop 26 times (i = 25..0): {
(
i--, push to b stack:({}[()]<>)
<
put 122 from a stack under i: ({}<(<>({})<>)>)
i times push letter-1: {({}[()]<(({})[()])>)}
replace top 0 with 26-i: ({}({})<>[({})]<>(((()()()){}){}){}())
devide by two: ((<>)<>{<({}[()])><>([{}]())<>}<>[{}]<>{})
push 10 (\n): ((()()()()()){})
>
flip stack back: <>
push i--: )
}
flip to results stack: <>

• This should be readable enough as is. You are talking about Brain-Flak, right? – Erik the Outgolfer Oct 26 '16 at 17:13

# Jelly, 15 13 bytes

-2 bytes thanks to @miles (formed a niladic chain I suspected existed but did not form)

ØaJ’H⁶ẋżṫJ$ṚY  TryItOnline! ### How? ØaJ’H⁶ẋżṫJ$ṚY - Main link
Øa            - alphabet yield -> ['a', 'b', 'c', ..., 'y', 'z']
J           -    range(length)      -> [1, 2, 3, ..., 25, 26]
’          -    decrement          -> [0, 1, 2, ..., 24, 25]
H         -    halve              -> [0,.5  1, ..., 12, 12.5]
⁶        -    literal [' ']
ẋ       -    repeat list        -> [[], [], [' '], ..., 12x' ', 12x' ']
$- last two links as a monad J - range(length) -> [1, 2, 3, ..., 25, 26] ṫ - tail (vectorises) -> [['a'-'z'], ['b'-'z'], ..., ['y','z'], ['z']] ż - zip -> [[[],['a'-'z']], [[],['b'-'z']], ..., [12x' ',['y','z']], [12x' ',['z]]] Ṛ - reverse whole array Y - join with line feeds (implicit print)  • I found a way to form a niladic chain starting with the alphabet ØaJ’H⁶ẋżṫJ$ṚY that saves 2 bytes – miles Oct 26 '16 at 1:54
• Do you think the explanation is correct? – Jonathan Allan Oct 26 '16 at 17:08
• Yeah just think of it as a monadic chain with a single argument being the alphabet – miles Oct 26 '16 at 17:41

# C, 72 68 bytes

m(i){for(char*k=&k[i=26];i;printf("%*c%s\n",--i/2+1,0,k))*--k=64+i;}


# 05AB1E, 5 bytes

A.s.c


Try it online!

A.s.c
A     Push 'abcdefghijklmnopqrstuvwxyz'
.s   Push suffixes starting from the shortest one
.c Centralize focused on the left


# Turtlèd, 70 68 bytes

note the trailing space

#abcdefghijklmnopqrstuvwxyz#' -{ -{ +.r_}' l[ l-]d,(*@!' r)(!@*)_}'


## How it works:

#abcdefghijklmnopqrstuvwxyz#              Set string var to this value
' -           write space on first grid cell, string pointer-=1
{                                    } While cell is space
-                 decrement string pointer
{     }    While cell is space
+.       increment string pointer, write pointed char
r      move right
_     write non-space if pointed char is last char

'[space]   write space on cell
l        move left
[ l-]   move left, pointer-- until cell's space
d, move down, write character var \
(initially *)

(*     ) if cell is *
@!     set char var=!
' r  write space over *, move right

(!    ) if cell is !
@*    set char var=*
'[space] write space over !

_ (explanation below)
write (*|!) if pointed char is last char

'[space]    Write space


It uses the string var to contain the alphabet. Each iteration, it reduces the index by one, until it wraps around, and halts, after getting to the last line. For the alternating indents, it uses the char var. Each iteration it checks the char var and flips it. if it was * it shifts right, so the first character aligns, otherwise not, so the last character aligns.

## Perl, 44 bytes

This is a port of @xnor's answer.

$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--  Needs -E (or -M5.010) to run : perl -E '$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--';


# PHP, 71 Bytes

for(;++$i<27;)echo str_pad(substr(join(range(a,z)),-$i),26," ",2)."\n";

• (26-$i)/213-$i/2 – manatwork Oct 26 '16 at 7:01
• Will it throw an error if you removed the last colon? Also, would be nice if you provided a link to an online website with example, ex. sandbox.onlinephpfunctions.com – RedClover Jan 5 '18 at 13:37

# Java 7 ,128 127 bytes

Saved 1 byte.Thanks to kevin.

String c(int n,String s,char v,String d){String c="";for(int j=0;j++<(n-1)/2;c+=" ");return n>0?c(--n,s=v+s,--v,d+c+s+"\n"):d;}


# ungolfed

  class A {

public static void main(String[] args) {
System.out.print(c(26, "", (char)122, ""));
}
static String c(int n, String s, char v, String d){

String c = "";

for (int j = 0; j++ < (n - 1)/2; c += " ");

return n > 0 ? c(--n, s = v + s, --v, d + c + s + "\n" ) : d;
}
}


Without an passing 122 in a function

# 132 bytes

String c(String s,int n,String d){String c="";int v=96,j=0;for(;j++<(n-1)/2;c+=" ");return n>0?c(s=(char)(v+n--)+s,n,d+c+s+"\n"):d;}


# ungolfed

  class A{

public static void main(String[] args) {
System.out.print(c("",26,""));

}
static String c(String s, int n, String d) {
String c = "";
int v = 96,j=0;
for (; j++ < (n - 1)/2; c += " ");
return n > 0 ? c(s = ( char) (v + n--) + s, n, (d + c + s + "\n")) : d;
}
}

• You can remove the = at d+=c+s+"\n". Also, you might want to format your ungolfed code a bit with indentations. I noticed that with some of your other answers as well. :) – Kevin Cruijssen Oct 26 '16 at 6:56
• oops! i did this mistake again,Shame to me. ......ok @KevinCruijssen i am on it. – Numberknot Oct 26 '16 at 7:20
• Can't you replace the s=v+s in the recursion with s+=v? – Roman Gräf Oct 26 '16 at 13:40
• No..because the letters pattern are in backward. – Numberknot Oct 26 '16 at 13:45

## Ruby, 64 bytes

(0..26).each{|x|puts' '*(12-x/2)+('a'..'z').to_a[~x..-1].join()}

• A few comments: You don't need to put the brackets after join Calling each instead of map is unnecessary, since we don't care about what we're returning You can call last on a range – Lee W Oct 27 '16 at 19:05
• Instead of (0..26).map, try 27.times; instead of ('a'..'z').to_a, [*?a..?z]; and instead of .join, *"". – Jordan Nov 18 '17 at 4:17

# Japt, 16 bytes

;C¬£SpY/2 +CsYÃw ·


Try it online!

### Explanation:

;C¬£SpY/2 +CsYÃw ·
;C                  // Alphabet shortcut
¬                 // Split into an array of chars
£          Ã     // Map each item X and index Y by:
SpY/2           //  " " repeated floor(Y/2) times
+CsY      //  + alphabet.slice(Y)
w    // Reverse the array of lines
·  // Join with newlines


## REXX, 52 bytes

do i=1 to 26
say centre(right(xrange(a,z),i),26)
end


Output:

            Z
YZ
XYZ
WXYZ
VWXYZ
UVWXYZ
TUVWXYZ
STUVWXYZ
RSTUVWXYZ
QRSTUVWXYZ
PQRSTUVWXYZ
OPQRSTUVWXYZ
NOPQRSTUVWXYZ
MNOPQRSTUVWXYZ
LMNOPQRSTUVWXYZ
KLMNOPQRSTUVWXYZ
JKLMNOPQRSTUVWXYZ
IJKLMNOPQRSTUVWXYZ
HIJKLMNOPQRSTUVWXYZ
GHIJKLMNOPQRSTUVWXYZ
FGHIJKLMNOPQRSTUVWXYZ
EFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZ
CDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ


# Vim, 25 Keystrokes

:h<_␍jjYZZPqqPxYPr Yq12@q


Where ␍ is the Enter key, also sometimes notated as <cr>.

## Explanation

:h<_␍jjYZZ                 " get a-z
P                " initialize by pasting
qq              " start record macro @q
Px            " paste and remove the 1st char
YPr␣        " yank and paste and replace 1st char with space
Y       " yank the whole line again
q      " end recording
12@q  " call macro 12 @q times


I am new to ViM though -- I started in November. Wondering if there is a way to merge the initializing P with the one in the macro.

What is the "correct" way to test a golfed ViM sequence? I tested with \vi -u /dev/null. However in a VM even :h<_␍ doesn't work. Also not very sure why my ViM will move to the first non space character haha.

P.S. Before I moved to use OS X, I golfed in Hexagony with great tools... Now on OS X I don't do wine and thus not running the great tools for explanations and debugging. So started my journey with ViM!

# C# (.NET Core), 112 bytes

()=>string.Join("\n",new int[26].Select((_,i)=>"".PadLeft(12-i/2)+"abcdefghijklmnopqrstuvwxyz".Substring(25-i)))


Try it online!

()=>string.Join("\n", // OP doesnt want to output a sequence of string...
new int[26].Select((_,i)=> // yield range from 0 to 25
"abcdefghijklmnopqrstuvwxyz".Substring(25-i)))  // remove letters


# Tcl, 92 bytes

set a {}
time {set a [format %c [expr 123-[incr i]]]$a;puts [format %[expr 13+$i/2]s $a]} 26  Try it online! # tcl, 94 set a {} set i 123 time {set a [format %c [incr i -1]]$a;puts [format %[expr 74-$i/2]s$a]} 26


demo

In the middle of the process, I accidentaly got the italic version of the hat:

# tcl, 94

set a {}
set i 123
time {set a [format %c [incr i -1]]$a;puts [format %[expr$i/2-24]s $a]} 26  demo # tcl, 101 set a {} set i 123 while $i>97 {set a [format %c [incr i -1]]a;puts [format %[expr (i-48)/2]s a]}  demo In the middle of the process, I accidentaly got the italic version of the hat: # tcl, 99 set a {} set i 123 while$i>97 {set a [format %c [incr i -1]]$a;puts [format %[expr $i/2-24]s$a]}


demo

• 92? – ASCII-only Apr 26 '18 at 6:23
• @ASCII-only thanks! – sergiol Apr 27 '18 at 11:39

# Common Lisp, SBCL, 83 82 bytes

(dotimes(i 27)(format t"~26:@<~a~>
"(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZ"(- 26 i))))


### Explanation

(dotimes(i 27) ; loop from i=0 to i=26
(format t"~26:@<~a~>
"(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZ"(- 26 i))))
;print out part of alphabet starting from character number 26-i (counting from zero)
;using justification (~26:@<~a~>) to center with weight 26 characters


-1 using sugestion by ASCII-only to use <enter> instead of ~%

• 82 – ASCII-only Apr 26 '18 at 7:19

# T-SQL, 107 bytes

DECLARE @t VARCHAR(99)=SPACE(13),@ INT=27a:SET @t=STUFF(@t,@/2,@%2,CHAR(@+95))PRINT @t
SET @-=1IF @>1GOTO a


Modifies the string for each line by cramming in the correct letter at the correct position using the SQL fuction STUFF(). Formatted:

DECLARE @t VARCHAR(99)=SPACE(13), @ INT=27
a:
SET @t=STUFF(@t,@/2,@%2,CHAR(@+95))
PRINT @t
SET @-=1
IF @>1 GOTO a


@/2 uses integer division (no remainder) to determine the position to insert the letter. @%2 is the MODULO function, and flips between 0 (insert the letter) and 1 (overwrite a space).

If you prefer capitial letters, use CHAR(@+63) instead (doesn't change our byte count).

# Perl 5, 40 38 bytes

-2 bytes thanks to @Dom Hastings

say$"x(13+--$x/2),@a[$x..-1]for@a=a..z  Try it online! • Came up with a slightly different variation for -2: Try it online! – Dom Hastings Apr 27 '18 at 19:56 # Stax, 7 bytes ô2òΘé8└  Run and debug it # Haskell (Lambdabot), 73 bytes unlines[([1..div(26-length x)2]>>" ")++x|x<-reverse.init$tails['a'..'z']]


same length:

do x<-reverse.init$tails['a'..'z'];([1..div(26-length x)2]>>" ")++x++"\n"  I use init.tails or tail.inits with a possible reverse in front in pretty much every challenge; I wish they would add it to Prelude already. ## Python 2, 66 64 bytes i=91;exec'i-=1;printmap(chr,range(i,91))[2::5].center(26);'*26  # Groovy, 53 bytes ('z'..'a').each{println((it..'z').join().center(26))}  # Output:  z yz xyz wxyz vwxyz uvwxyz tuvwxyz stuvwxyz rstuvwxyz qrstuvwxyz pqrstuvwxyz opqrstuvwxyz nopqrstuvwxyz mnopqrstuvwxyz lmnopqrstuvwxyz klmnopqrstuvwxyz jklmnopqrstuvwxyz ijklmnopqrstuvwxyz hijklmnopqrstuvwxyz ghijklmnopqrstuvwxyz fghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz defghijklmnopqrstuvwxyz cdefghijklmnopqrstuvwxyz bcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz  ## QBIC, 57 bytes [25,0,-1|Y=Z[1,a/2|Y=Y+@ |]X=Z[a,25|X=X+$CHR(65+|c)]?Y+X  This one works surprisingly well with QBIC' FOR loops. Explanation (of previous version - same principle applies): [26,1,-1| Loops from 26 to 1, decrementing 'a' 'a' is used to determine the number of spaces per line and the last letter we want to print Y=Z Z is always an empty string in this program, Y will hold the spaces we need to center this line [1,a/2|Y=Y+@ |] Add a space to Y equal to half the value of 'a', giving us a center alignment X=Z X holds the characters we need on this line, reset it [a,26| FOR c = a to 26 --> loop over the last part of the alphabet X=X+CHR\$(64+|c)]  Convert c+64 to ASCII and append
?Y+X               Print the spaces and the letters

<outer FOR loop is closed by QBIC>


Output:

            Z
YZ
XYZ
WXYZ
VWXYZ
UVWXYZ
TUVWXYZ
STUVWXYZ
RSTUVWXYZ
QRSTUVWXYZ
PQRSTUVWXYZ
OPQRSTUVWXYZ
NOPQRSTUVWXYZ
MNOPQRSTUVWXYZ
LMNOPQRSTUVWXYZ
KLMNOPQRSTUVWXYZ
JKLMNOPQRSTUVWXYZ
IJKLMNOPQRSTUVWXYZ
HIJKLMNOPQRSTUVWXYZ
GHIJKLMNOPQRSTUVWXYZ
FGHIJKLMNOPQRSTUVWXYZ
EFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZ
CDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ

• Doesn't match the OP. – Magic Octopus Urn Oct 26 '16 at 17:43
• @carusocomputing it does now. – steenbergh Oct 26 '16 at 21:50

## Racket 137 bytes

(for((n(range 122 96 -1)))(for((i(floor(/(- n 97)2))))(display #\space))
(for((i(range n 123)))(display(integer->char i)))(displayln ""))


Ungolfed:

(define (f)
(for ((n (range 122 96 -1)))
(for ((i (floor(/(- n 97)2))))
(display #\space))
(for ((i (range n 123)))
(display (integer->char i)))
(displayln "")))


Testing:

(f)


Output:

            z
yz
xyz
wxyz
vwxyz
uvwxyz
tuvwxyz
stuvwxyz
rstuvwxyz
qrstuvwxyz
pqrstuvwxyz
opqrstuvwxyz
nopqrstuvwxyz
mnopqrstuvwxyz
lmnopqrstuvwxyz
klmnopqrstuvwxyz
jklmnopqrstuvwxyz
ijklmnopqrstuvwxyz
hijklmnopqrstuvwxyz
ghijklmnopqrstuvwxyz
fghijklmnopqrstuvwxyz
efghijklmnopqrstuvwxyz
defghijklmnopqrstuvwxyz
cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz