| Bytes | Lang | Time | Link |
|---|---|---|---|
| 007 | Japt R | 201110T095505Z | Shaggy |
| 101 | AWK | 241204T181022Z | xrs |
| 091 | Tcl | 170217T001259Z | sergiol |
| 099 | Elixir | 210721T195708Z | Dom Hast |
| 037 | Cheddar | 161026T034827Z | Downgoat |
| 004 | Vyxal C | 210720T171256Z | Aaroneou |
| 046 | PowerShell | 201110T160441Z | Veskah |
| 006 | Canvas | 181211T130851Z | dzaima |
| 057 | PHP | 180205T071027Z | Titus |
| 007 | Stax | 180427T230636Z | recursiv |
| 038 | Perl 5 | 180105T143946Z | Xcali |
| 107 | TSQL | 180427T145743Z | BradC |
| 082 | Common Lisp | 170216T230552Z | user6516 |
| 136 | Java 10 | 180427T070801Z | Jaden Le |
| 022 | Gol><> | 180427T044841Z | Bubbler |
| 020 | APL Dyalog Classic | 180205T012541Z | ngn |
| 075 | uBASIC | 180131T194909Z | Taylor R |
| 082 | Yabasic | 180131T194318Z | Taylor R |
| 068 | JavaScript ES6 | 161025T225905Z | darrylye |
| 005 | 05AB1E | 170325T092027Z | Erik the |
| 039 | J | 180105T102248Z | cole |
| 016 | Charcoal | 180105T081552Z | Charlie |
| 112 | C# .NET Core | 171116T164552Z | aloisdg |
| 101 | F# .NET Core | 171117T094204Z | aloisdg |
| 054 | Ruby | 171118T023749Z | Justin M |
| 125 | C# Visual C# Compiler | 171116T171301Z | Barodus |
| 025 | Vim | 171116T070727Z | Sunny Pu |
| 066 | VBA | 171116T041315Z | Taylor R |
| 008 | SOGL V0.12 | 171006T165259Z | dzaima |
| 012 | Pyke | 161026T120451Z | Blue |
| 052 | REXX | 170328T180131Z | idrougge |
| 016 | Japt | 170325T024224Z | Oliver |
| 133 | Javascript | 170216T234644Z | Spydercr |
| 068 | C | 161026T183318Z | user5634 |
| 175 | C# | 161118T221521Z | Pete Ard |
| 137 | Racket | 161029T091936Z | rnso |
| 059 | R | 161026T070329Z | Billywob |
| 057 | QBIC | 161026T165358Z | steenber |
| 053 | Groovy | 161026T174406Z | Magic Oc |
| 013 | Jelly | 161025T233019Z | Jonathan |
| 064 | Ruby | 161026T164107Z | Manny42 |
| 244 | BrainFlak | 161026T152550Z | MegaTom |
| nan | Java 7 | 161026T054003Z | Numberkn |
| 064 | Python 2 | 161026T132933Z | Blue |
| 071 | PHP | 161025T230051Z | Jör |
| 044 | Perl | 161026T092545Z | Dada |
| 073 | Haskell Lambdabot | 161026T091539Z | BlackCap |
| 068 | Turtlèd | 161026T032927Z | Destruct |
| 052 | Python 2 | 161025T232853Z | xnor |
| 015 | Pyth | 161026T000314Z | TheBikin |
| 013 | 05AB1E | 161025T224440Z | Emigna |
| 070 | Python 2 | 161025T224927Z | Karl Nap |
Japt -R, 7 bytes
;CÔåi û
;CÔåi û
;C :Lowercase alphabet
Ô :Reverse
å :Cumulatively reduce by
i : Prepending
û :Centre pad (left biased) with spaces to length of longest
:Implicit output, joined with newlines
AWK, 101 bytes
@load "ordchr";{for(i=26;i--;print){for(j=int(i/2);j--;)printf" ";for(k=i+96;k++<122;)printf chr(k)}}
107 bytes
@load "ordchr";{for(i=122;i-->96;print){for(j=int((i-96)/2);j--;)printf" ";for(k=i;k++<122;)printf chr(k)}}
@load "ordchr"; # int to alpha lib
{for(i=122;i-->96;print){ # z -> a down the tree
for(j=int((i-96)/2);j--;)printf" "; # half as much space
for(k=i;k++<122;)printf chr(k)}} # print alphabet
Tcl, 91 bytes
set a {}
time {puts [format %[expr 13+[incr i]/2]s [set a [format %c [expr 123-$i]]$a]]} 26
With the help of ChatGPT
set a {}
time {set a [format %c [expr 123-[incr i]]]$a;puts [format %[expr 13+$i/2]s $a]} 26
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
set a {}
set i 123
while \$i>97 {set a [format %c [incr i -1]]$a;puts [format %[expr ($i-48)/2]s $a]}
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]}
Elixir, 99 bytes
import Enum
reduce 25..0,' ',&(IO.puts(&2++slice(?a..?z,&1,26))&&rem(&1,2)>0&& &2||tl&2)
Trying to find another way to generate the space string but can't make anything shorter...
Cheddar, 50 45 42 37 bytes
25|>0=>i->print" "*(i/2|0)+(65+i)@"90
Straightforward, but utilizes cheddar's consise ranging syntax (both numerical and alphabetical)
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 Z
Vyxal C, 4 bytes
kz¦R
Explanation:
kz # Lowercase backwards alphabet
¦ # Prefixes
R # Reverse each
# 'C' flag - Center top of stack, join on newlines, and print
PowerShell, 62 51 46 bytes
-11 bytes thanks to mazzy reminding me of a function
-5 bytes thanks to mazzy
25..0|%{' '*($_-shr1)+-join('a'..'z')[$_..25]}
Uses the -replace-shift-right 1 trick to bypass banker's rounding. Additionally, uses a character range to generate the alphabet.
PHP, 68 58 57 bytes
edit #1: a different approach with left padding and string concatenation + uppercase
edit #2: shorter padding expression
while($i++<26)printf("
%".($i+26>>1).s,$s=chr(91-$i).$s);
Add two bytes if a leading newline is disallowed:
while($i++<26)printf("%".($i+26>>1)."s
",$s=chr(91-$i).$s);
Run with -nr or try them online.
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).
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 ~%
Java 10: 136 bytes
GOLFED
for(int i=25;i>=0;i--){for(int j=0;j<i/2;j++){System.out.print("
");}System.out.println("abcdefghijklmnopqrstuvwxyz".substring(i,26));}}
UNGOLFED
class a {
public static void main(String[] args) {
for (int i = 25; i >= 0; i--) {
for (int j = 0; j < i/2; j++) {
System.out.print(" ");
}
System.out.println("abcdefghijklmnopqrstuvwxyz".substring(i,26));
}
}
}
RESULTS
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
Gol><>, 22 bytes
asFa`z9sL-F:M|L2,R` |H
How it works
asFa`z9sL-F:M|L2,R` |H
asF | Repeat 26 times...
a Push 10 (\n)
`z Push z
9sL-F | Repeat (25 - loop counter(L)) times...
:M Clone the top and decrement
L2,R Repeat (L / 2) times...
` Push 32 (space)
H Output the entire content (top to bottom) and halt
Basically, this constructs the entire output backwards.
There are two division operators in Gol><>, namely , (floating division) and S, (integer division). Luckily R (repeat X times) floors its argument, so I could save a byte.
uBASIC, 75 bytes
Anonymous function that takes no input and outputs to the console.
Slightly different approach than other BASIC answers as uBASIC's integer division functions differently - (25/2 equals 12 rather than 13)
0ForI=2To27:?Tab(13-I/2);:ForJ=28-ITo26:?Left$(Chr$(J+96),1);:NextJ:?:NextI
Yabasic, 82 bytes
A jolly solution that takes no input and outputs to the console.
For i=1To 26
For j=1To 13-i/2
?" ";
Next
For j=27-i To 26
?Chr$(j+96);
Next
?
Next
JavaScript (ES6), 85 75 69 68 bytes
for(s=a='',x=36;--x>9;)s+=` `.repeat(x/2-5)+(a=x.toString(36)+a)+`
`
-1 byte thanks to @l4m2.
05AB1E, 5 bytes
A.s.c
A.s.c
A Push 'abcdefghijklmnopqrstuvwxyz'
.s Push suffixes starting from the shortest one
.c Centralize focused on the left
J, 39 bytes
echo(' '<@#"0~2#i._13),&><@|.\u:90-i.26
I see capital letters in some submissions so I assume it's OK to use them. If not, then add a byte to convert to lowercase.
Explanation
See my (almost identical) answer to this (duplicate) question.
The only difference is in generating the alphabet, where I generate ZYX...CBA and then reverse each prefix of that string to give the desired parts. I feel like there is a way to avoid that but I'm tired right now and this is the best way of fixing it that I could think of.
Charcoal, 16 bytes
F²⁷«P⮌…⮌βι¿﹪ι²↓↙
Link is to the verbose version of the code. I'm sure there must be a shorter way to do this in Charcoal.
C# (.NET Core), 112 bytes
()=>string.Join("\n",new int[26].Select((_,i)=>"".PadLeft(12-i/2)+"abcdefghijklmnopqrstuvwxyz".Substring(25-i)))
()=>string.Join("\n", // OP doesnt want to output a sequence of string...
new int[26].Select((_,i)=> // yield range from 0 to 25
"".PadLeft(12-i/2)+ // add spaces to center
"abcdefghijklmnopqrstuvwxyz".Substring(25-i))) // remove letters
F# (.NET Core), 101 bytes
[0..25]|>Seq.map(fun i->"".PadLeft(12-i/2)+"abcdefghijklmnopqrstuvwxyz".[25-i..])|>String.concat "\n"
A naive port of my C# answer
C# (Visual C# Compiler), 125 bytes
()=>{var s="";for(var c='z';c>'`';c--){for(var i='a';i<'{';i++)s+=i<c?' ':i;s+="\n";}Console.WriteLine(s.Replace(" "," "));}
Highlights: seen how char is a numeric datatype, let's use it for the loop. The value ranges from 'a' to 'z', which is awesome! We can just add a char to a string, so that's another back-curling - but now convenient - feature.
The outer counter counts from z to a, the inner counter from a to z. The inner loop checks if the inner counter is more than the outer, if so print a space, else print the counter character. After every outer iteration we print a newline, after the function completes we print it to the console after replacing a double space with a single one (very, very wasteful line, but included in character count).
I couldn't think of any more abuse in a language specification than this.
EDIT: added lambda function specification and call in accordance to alois' remark.
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!
VBA, 68 66 Bytes
Anonymous VBE immediate function that takes no input and outputs to the VBE immediate window
For i=1To 26:?:?Spc(13-i/2);:For j=27-i To 26:?Chr(j+96);:Next j,i
SOGL V0.12, 8 bytes
z{Xf}¹№╚
Explanation:
z push the lowercase alphabet
{ } for each, pushing current character
X remove the character from the stack as it's not needed
f push the remaining string, including the current character, what the loop has to traverse
¹ wrap all that in an array
№ reverse vertically
╚ center horizontally - this centers it exactly as required :D
Pyke, 18 12 bytes
26Fed*Gi>+)X
26F ) - for i in range(26):
ed* - (i//2)*" "
+ - concatenate ↑ and ↓
Gi> - alphabet[i:]
X - splat(^) (print list reversed with newlines)
Or 10 bytes noncompetitive
26DXF2GR>c
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
Japt, 16 bytes
;C¬£SpY/2 +CsYÃw ·
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
Javascript, 133 Bytes
for(i=26,s="";i>0;i--){for(k=26-i+Math.floor((i+1)/2),l=34+Math.floor((i+1)/2);k>0;k--,l--)k>27-i?s+=" ":s+=l.toString(36);s+="<br>"}
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;}
C#, 175 Bytes:
Golfed:
string H(){string o="",a="abcdefghijklmnopqrstuvwxyz";int p=12,i=0;for(i=0;i<=26;i++){o+=a.Substring(26-i,i).PadLeft(p+i)+"\n";if(i==0||i==1)continue;p-=i%2==0?1:0;}return o;}
Ungolfed:
public string H()
{
string o = "", a = "abcdefghijklmnopqrstuvwxyz";
int p = 12, i=0;
for (i = 0; i <= 26; i++)
{
o += a.Substring(26 - i, i).PadLeft(p+i)+ "\n";
if (i == 0 || i == 1) continue;
p -= i % 2 == 0 ? 1 : 0;
}
return o;
}
Test:
Console.Write(new DrawAnAlphabetHat().H());
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
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
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
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
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
Jelly, 15 13 bytes
-2 bytes thanks to @miles (formed a niladic chain I suspected existed but did not form)
ØaJ’H⁶ẋżṫJ$ṚY
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)
Ruby, 64 bytes
(0..26).each{|x|puts' '*(12-x/2)+('a'..'z').to_a[~x..-1].join()}
Brain-Flak, 244 bytes
((((((()()()()())){}{}){}){}()){})((((()()()){}){}()){}){(({}[()]<>)<({}<(<>({})<>)>){({}[()]<(({})[()])>)}({}({})<>[({})]<>(((()()()){}){}){}())((<>)<>{<({}[()])><>([{}]())<>}<>[{}]<>{}){({}[()]<((((()()()()){}){}){})>)}((()()()()()){})><>)}<>
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: ((<>)<>{<({}[()])><>([{}]())<>}<>[{}]<>{})
add spaces: {({}[()]<((((()()()()){}){}){})>)}
push 10 (\n): ((()()()()()){})
>
flip stack back: <>
push i--: )
}
flip to results stack: <>
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;
}
}
Python 2, 66 64 bytes
i=91;exec'i-=1;print`map(chr,range(i,91))`[2::5].center(26);'*26
PHP, 71 Bytes
for(;++$i<27;)echo str_pad(substr(join(range(a,z)),-$i),26," ",2)."\n";
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--';
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.
Turtlèd, 70 68 bytes
note the trailing space
#abcdefghijklmnopqrstuvwxyz#' -{ -{ +.r_}' l[ l-]d,(*@!' r)(!@*)_}'
Try it online!
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
Human-readable explanation(?):
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.
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
Pyth, 15 bytes
j_m+*/d2\ >GdUG
A program that prints the result to STDOUT.
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
05AB1E, 15 13 bytes
A.svy12N;ï-ú,
Try it online! (slightly different from above as ú isn't on TIO yet)
Explanation
- Push alphabet
- Compute the suffixes of the alphabet
- Prepend 12-index/2 spaces
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:]