| Bytes | Lang | Time | Link |
|---|---|---|---|
| 090 | Swift 6 | 250428T145519Z | macOSist |
| 016 | ☾ | 250319T001753Z | noodle p |
| 016 | Vyxal 3 | 250417T085304Z | Themooni |
| 048 | Raku Perl 6 rakudo | 250416T155401Z | xrs |
| 320 | Bespoke | 250415T101227Z | Josiah W |
| 118 | Tcl | 170905T235230Z | sergiol |
| 077 | AWK | 250312T211810Z | xrs |
| 014 | Pip l | 210502T005254Z | DLosc |
| 091 | brainfuck | 250131T155607Z | Weird Gl |
| 060 | tinylisp 2 | 240822T215028Z | DLosc |
| 258 | Assembly nasm | 240822T163214Z | Glory2Uk |
| 007 | Vyxal 3 j | 240219T132304Z | pacman25 |
| 025 | Uiua | 231018T082124Z | Matthew |
| 096 | C89 | 231018T063107Z | Pignotto |
| 025 | CJam | 170907T132843Z | Ven |
| 1431 | Pyramid Scheme | 220319T001228Z | emanresu |
| 084 | Elixir | 210721T180032Z | Dom Hast |
| 009 | Vyxal | 210501T235930Z | hyperneu |
| 041 | Zsh | 210512T123844Z | pxeger |
| 023 | BRASCA | 210512T122812Z | RezNesX |
| 082 | Lua | 210512T120259Z | wen1k |
| 024 | Vyxal | 210510T104535Z | SegFault |
| 253 | Splinter | 210502T011016Z | emanresu |
| 066 | Excel | 210502T001928Z | Axuary |
| 011 | Japt R | 170905T202420Z | Shaggy |
| 069 | Python 3 | 200930T222040Z | mehbark |
| 101 | Rockstar | 200929T143618Z | Shaggy |
| 021 | Pyth | 200929T134828Z | PkmnQ |
| 037 | Perl 5 + p | 170906T084850Z | Dom Hast |
| 012 | Jelly | 170905T200329Z | hyperneu |
| 016 | 05AB1E | 200928T213339Z | Makonede |
| 054 | Forth gforth | 191012T080347Z | Bubbler |
| 163 | Whitespace | 191009T142511Z | Dorian |
| 016 | Brachylog | 191009T072621Z | Unrelate |
| 058 | Ruby | 191009T002713Z | Value In |
| 601 | Poetic | 181125T035958Z | JosiahRy |
| 014 | Gaia | 190409T171255Z | Giuseppe |
| 021 | Dyalog APL | 170907T121245Z | Ven |
| 049 | ><> | 190313T192420Z | Emigna |
| 022 | K4 | 181124T113838Z | mkst |
| 114 | C# .NET Core | 180503T123833Z | Hille |
| 115 | TSQL | 180502T163226Z | BradC |
| 009 | Stax | 180421T193425Z | Khuldrae |
| 118 | Swift | 180426T144207Z | user3151 |
| 082 | Common Lisp | 170905T212007Z | Renzo |
| 064 | SmileBASIC 3 | 180421T190519Z | snail_ |
| 156 | Emojicode | 180423T080311Z | X1M4L |
| 087 | Rust | 180422T071422Z | Arcterus |
| 082 | SNOBOL4 CSNOBOL4 | 180421T154800Z | Giuseppe |
| 071 | Python 3 | 180421T145902Z | PikalaxA |
| 127 | Go | 180421T134942Z | Dust |
| 113 | PHP | 180420T195152Z | Francisc |
| 006 | Canvas | 180330T112404Z | dzaima |
| 008 | SOGL V0.12 | 170905T200656Z | dzaima |
| 022 | Recursiva | 170907T101712Z | 0xffcour |
| 134 | Visual Basic .NET Mono | 180131T182011Z | Taylor R |
| 079 | Yabasic | 180131T181621Z | Taylor R |
| 100 | MYBASIC | 180131T054454Z | Taylor R |
| 074 | uBASIC | 180131T053938Z | Taylor R |
| 071 | Kotlin | 170908T204558Z | jrtapsel |
| 019 | Implicit | 170905T231850Z | MD XF |
| 113 | Acc!! | 171110T155920Z | qqq |
| 021 | J | 171002T220026Z | Jonah |
| 043 | Vim | 171030T125008Z | BlackCap |
| 053 | Haskell | 171030T114039Z | BlackCap |
| 031 | q/kdb+ | 170906T124001Z | mkst |
| 083 | Python 2 | 170906T224322Z | Koppany |
| 065 | VBA | 171002T193656Z | Taylor R |
| 069 | Python 3 | 170928T085704Z | Yalnix |
| nan | Java | 170906T223138Z | Jimmy Jo |
| 097 | /// | 170906T142738Z | Jakube |
| 133 | C++ | 170905T224428Z | HatsuPoi |
| 105 | Java OpenJDK 8 | 170909T113225Z | Olivier |
| 060 | Ruby | 170909T003305Z | David Lj |
| 055 | PHP | 170906T202845Z | CR Drost |
| 046 | vim | 170908T194712Z | Ray |
| 206 | Java | 170908T103530Z | Akhil KC |
| 008 | Pyke | 170908T091721Z | Blue |
| 076 | AWK | 170908T023441Z | Robert B |
| 050 | sed 4.2.2 + Bash | 170907T170210Z | Dennis |
| 083 | Python | 170907T152912Z | Jacob Ga |
| 014 | Pyth | 170907T022552Z | Stan Str |
| 015 | Husk | 170907T140008Z | Erik the |
| 038 | Retina | 170907T140909Z | Martin E |
| 082 | C | 170907T130646Z | Toby Spe |
| 064 | Bash + coreutils | 170907T123543Z | Toby Spe |
| 045 | Octave | 170905T222738Z | Luis Men |
| 093 | Twig | 170907T094223Z | Ismael M |
| 102 | SimpleTemplate | 170907T013003Z | Ismael M |
| 105 | brainfuck | 170907T002725Z | Conor O& |
| 082 | Javascript | 170906T230218Z | Igor Sow |
| 043 | Cubix | 170905T222707Z | MickyT |
| 119 | brainfuck | 170906T184232Z | Jerry |
| 093 | Clojure v1.8 | 170906T193549Z | Chris |
| 037 | Perl 6 | 170905T220541Z | Ramillie |
| nan | 170906T181313Z | Brad Gil | |
| 3846 | Octave | 170906T180752Z | rahnema1 |
| 052 | Ruby | 170906T175921Z | Snack |
| 048 | DUP | 170906T174600Z | M L |
| 167 | VB | 170906T080505Z | user7401 |
| 048 | QBIC | 170906T162641Z | steenber |
| 064 | Python 2 | 170905T204245Z | Artemis_ |
| 044 | Perl 6 | 170906T143018Z | Massa |
| 049 | Perl 5 | 170905T204736Z | Xcali |
| 8718 | C# .NET Core | 170906T094213Z | Grzegorz |
| 089 | SpecBAS | 170906T074912Z | Brian |
| 027 | K oK | 170905T211938Z | mkst |
| 072 | C gcc | 170905T205021Z | scottine |
| 017 | RProgN 2 | 170906T011204Z | ATaco |
| 073 | Mathematica | 170905T205517Z | ZaMoC |
| 011 | V | 170905T195240Z | DJMcMayh |
| 074 | JavaScript | 170905T211227Z | user7234 |
| 011 | Charcoal | 170905T200254Z | totallyh |
| 082 | PHP | 170905T220554Z | halfmang |
| 007 | 05AB1E | 170905T200754Z | Adnan |
| 052 | Haskell | 170905T210533Z | nimi |
| 042 | PowerShell | 170905T194434Z | AdmBorkB |
| 060 | Bash + GNU sed | 170905T203119Z | Digital |
| 076 | JavaScript ES6 | 170905T195047Z | Arnauld |
| 057 | Python 2 | 170905T201416Z | lynn |
| 085 | Bubblegum | 170905T202307Z | totallyh |
| 067 | Python 2 | 170905T195311Z | Rod |
| 016 | Japt | 170905T194928Z | Oliver |
| 015 | Pyth | 170905T201906Z | Mr. Xcod |
| 073 | Python 3 | 170905T194902Z | caird co |
| 010 | 05AB1E | 170905T195419Z | scottine |
| 015 | Pyth | 170905T195035Z | Maltysen |
| 055 | R | 170905T194310Z | Giuseppe |
Swift 6, 90 bytes
(0..<26).map{print({String.init}()(" ",25-$0)+"ZYXWVUTSRQPONMLKJIHGFEDCBA".dropFirst($0))}
Vyxal 3, 16 bytes
26ɾ⇄ƛ␣×kAn⊖⇄&f“,
26ɾ⇄ƛ␣×kAn⊖⇄&f“,
ƛ # map over
26ɾ⇄ # range 26..1
n⊖ # take the first n from
kA # uppercase alphabet
⇄& # reverse and append to...
␣× # " " times n
f“, # flatten, join on empty string an print each line
💎
Created with the help of Luminespire.
<script type="vyxal3">
␣,
26ɾ⇄ƛ␣×kAn⊖⇄&f“,
</script>
<script>
args=[]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
Raku (Perl 6) (rakudo), 48 bytes
$!=26;put " "x$!--~($_…'A').join for 'Z'…'A'
$!=26; # starting padding
put " "x$!-- # print padding
~ # append
($_…'A') # string from x to 'A'
.join # remove spaces between letters
for 'Z'…'A' # letter to start from
Bespoke, 320 bytes
hey,so we placed letters through gridlike patterns in code
so each of them go once through grids
but it was so bugged;it actually appeared so cool
letters are in a triangle pattern,forming beacons
it then hit us:people,make alphabet spot-lights to entirely recreate it
show letters all in a set,as a triangular-shaped ax
Prints with a single trailing newline.
Tcl, 118 bytes
time {set c $n
set s [format %[incr n -1]s ""]
time {set s $s[format %c [expr 65+[incr c -1]]]} $c
puts $s} [set n 26]
AWK, 77 bytes
END{for(i=26;i--;)for(x=i*2+1;x--;)printf(x?x>i?FS:sprintf("%c",x+65):"A\n")}
Pip -l, 18 16 14 bytes
-2 bytes and a more elegant approach thanks to emanresu A
RsX,26.R*\$.AZ
Explanation
RsX,26.R*\$.AZ
AZ ; Uppercase alphabet
\$. ; Scan on concatenation (gives a list of prefixes)
R* ; Reverse each prefix
,26 ; Range(26)
sX ; That many spaces (gives a list of strings)
. ; Concatenate the two lists itemwise
R ; Reverse the resulting list
; Autoprint, one element per line (-l flag)
brainfuck, 91 bytes
++++++++++[-<<+++++++++>>>+++>+++>+<<<]>---->++<[-[->.<<+>]<+[->+<<+<.->>]<-[-<+>]>>>>.<<-]
This program uses a strategy similar to the one used by Conor O'Brien, but some changes were made in order to compress it. A short explanation of this code:
Set up (90='Z'=char 0 0 26=index 32=' ' 10='\n') with the pointer on index
++++++++++[-<<+++++++++>>>+++>+++>+<<<]>---->++<
[ While index != 0:
-[->.<<+>]<+ Print index minus 1 spaces
[->+<<+<.->>] Print letters from char to char minus index (always 'A')
<-[-<+>] Reset char to previous value minus 1
>>>>.<< Print '\n'
-] Substract one from index
tinylisp 2, 60 bytes
(w(} ,(m(\(N)(,(repeat 32 N)(,(m(p + 65)(to0 N))nl)))(to0 25
Explanation/ungolfed
(write ; Print this string:
(foldl concat ; Concatenate together all strings in this list:
(map ; Map
(lambda (N) ; this function:
(concat ; Concatenate
(repeat 32 N) ; a list of N 32s (spaces)
(concat ; with the concatenation of
(map ; Map
(partial + 65) ; a function that adds 65
(to0 N)) ; over the list of numbers from N down to 0
nl))) ; with a string containing a newline
; (Concatenating list of ints with string casts to string)
(to0 25)))) ; over the list of numbers from 25 down to 0
Assembly (nasm, x64, Linux), 258 bytes
This program outputs an ASCII-style "alphabet searchlight" (with a leading newline above).
To remove the first character of the string, the inc operator is applied to the register cl, then the output string length in dl is decremented.
global _start
_start:
mov dl,26 ;initiate the string length
mov ecx,m ;load the alphabet string
mov esi,n ;load the leading string
f: ;loop f label
mov edi,0 ;initiate loop x counter
x: ;loop x label
xchg ecx,esi;swap the registers
mov bl,1
mov al,4 ;print function
int 0x80 ;interrupt
inc edi ;counter++
cmp edi,2 ;if counter < 2
jnz x ;repeat
inc cl ;make the first letter disappear
dec dl ;decrement output length
cmp dl,0 ;if string is not empty
jnz f ;repeat
mov bl,0
mov al,1 ;call sys exit
int 0x80
m db "ZYXWVUTSRQPONMLKJIHGFEDCBA"
n db 0xa," "
Vyxal 3 j, 7 bytes
kZ€ƛd«Ḣ
kZ€ƛd«Ḣ
kZ€ # suffixes of uppercase reversed alphabet
ƛd«Ḣ # prepend spaces to make each double their length then remove the first space
💎
Created with the help of Luminespire.
Uiua, 25 bytes
;⍥(-1&p⊂↯∶@ -1,⇌+@A⇡.).26
Explanation:
.26 # Put 26 onto the stack twice
⍥( ) # Repeat 26 times
. # Copy the counter value
⇡ # Make an array of natural numbers less than counter
+@A # Add "A" to each element, getting ["A", "B",...]
⇌ # Reverse
-1, # Copy counter and subtract 1
↯∶@ # Make an array of space chars
⊂ # Join spaces with the letters
&p # Print the result
-1 # Subtract 1 from the original counter
; # Pop the counter from the stack
C89, 96 bytes
i,j;main(){for(;i<26;)++j>25?puts("ZYXWVUTSRQPONMLKJIHGFEDCBA"+i),j=++i:putchar(' ');return 0;}
int i, j;
int main()
{
while(i<26){
extern int puts();
extern int putchar();
if (++j > 25) {
puts("ZYXWVUTSRQPONMLKJIHGFEDCBA" + i);
j = ++i;
}
else {
putchar(' ');
}
}
return 0;
}
CJam, 25 bytes
Fixed. Thanks to Martin Ender for the help fixing it!
'[,65>W%_,,_Sf*W%\@f>.+N*
Explanation:
'[,65>W%_,,_Sf*W%\@f>.+N*
'[,65> e# From the cjam golfing tips, generate A-Z
W% e# Reverse the array: Z-A
_, e# Take the size of that range (so, 26)
, e# Make a range 0..25
_ e# Dupe that range
f* e# For each value of that range
S e# Repeat a space that amount of times
W% e# Reverse this list of strings
\ e# Swap the top and the second elements of the stack
@ e# Brings the first stack el. to the top
f> e# For each value in that range, remove N elements from the alphabet (generate ZYX..., until, CBA, BA, A).
.+ e# Vectorized append (appends space with the alphabet chunks)
N* e# Join with newline
Pyramid Scheme, 1431 bytes
^ ^
/ \ / \
/set\ /do \
^-----^ ^-----^
/a\ / \ /a\ /[\
--- /26 \--- ^---^
----- ^- -^
^- -^
/]\ -^
^---^ -^
^- -^ -^
^- -^ -^
^- -^ -^
/[\ / \ /[\
^---^ /set\ ^---^
^- -^ ^-----^ -^ -^
^- -^ /c\ /a\ / \ -^
/ \ / \--- ---/set\ -^
/set\ /do \ ^-----^ -^
^-----^ ^-----^ /a\ /-\ -^
/b\ /a\-^ /[\ --- ^---^ -^
--- ---/b\ ^---^ /a\ /1\ -^
---/ \ -^ --- --- /[\
/set\ -^ ^---^
^-----^ -^ ^- / \
/b\ /+\ /?\ / \ /out\
--- ^---^---^ /do \-----^
/ \ /b\ / \ ^-----^ -^
/-1 \---/out\ /c\ /[\ / \
----- ^----- --- ^---^ /chr\
/ \ ^- / \-----^
/chr\ ^- /out\ / \
^----- / \ -----^ /10 \
/ \ /set\ / \-----
/32 \ ^-----^ /chr\
----- /c\ /-\ -----^
--- ^---^ /+\
/c\ /1\ ^---^
--- --- /c\ / \
---/65 \
-----
Yes, I wrote this all by hand. It's kinda therapeutic...
Elixir, 84 bytes
import Enum
map 25..0,&(IO.puts List.duplicate(' ',&1)++reverse(slice ?A..?Z,0..&1))
Still want to find a way around that List.duplicate call....
Vyxal, 9 bytes
kA¦₄ʁ꘍RṘ⁋
could be -1 byte by replacing the ⁋ at the end with the j flag
-4 bytes from the initial working version thanks to ovs
some golfs were proposed by other people but they broke the answer
-2 bytes thanks to Aaron Miller
kA¦₄ʁ꘍RṘ Full Program
kA "ABC...XYZ"
¦ "A", "AB", "ABC", ..., "ABC...XYZ"
₄ 26
ʁ 0..25
꘍ a + " " * b (returns "A", "AB ", "ABC ", ...)
R Reverse each ("A", " BA", " CBA", ...)
Ṙ Reverse the entire list
⁋ Join on newlines
Zsh, 41 bytes
eval 1={A..Z}'$1;<<<${(l:#1-65:)}$1;'|tac
Explanation:
1={A..Z}'$1;<<<${(l:#1-65:)}$1;': construct the string1=A$1;<<<${(l:#1-65:)}$1; 1=B...1; 1=C...1; ... 1=Z...1;(with every letter fromAtoZin place of the{A..Z}in each case)evaluate that string aszshcode:1=A$1: prependA(or which ever letter is in that repetition) to the variable$1${(l:#1-65:)}: generate#1-65spaces:#1: Take the ASCII character code of the first character of$1- subtract
65. The first iteration will haveAas the first character of$1, the character code of which is65, and since65-65=0, no spaces will be printed. Then for further letters, another space will be added each time.
$1: and append the variable$1<<<: and print that with a newline
|tacand reverse the output line-wise
Zsh, 36 bytes
eval 2={A..Z}'$2;<<<$1$2;1+=\ ;'|tac
Lua, 82 bytes
s=' 'for i=90,65,-1 do o=s:rep(i-65)for j=i,65,-1 do o=o..s.char(j)end print(o)end
Human readable code:
s=' '
for i=90,65,-1 do
o=s:rep(i-65)
for j=i,65,-1 do
o=o..s.char(j)
end
print(o)
end
Vyxal, 704 24 bytes
₄ʀƛ:ʁṘƛ65+C;ṅ$ð*$+;Ṙ
Behind door number 3, we have this answer - again just prints out the string (Edit 1: never mind, it doesn't)
Splinter, 253 bytes
Z{\A\
}H{\C\BZ}A{\M\L\K\JG{\I\HD}D{\G\F\E\DH}D}E{\V\U\TB{\S\R\Q\PF{\O\NA}F}B}S{\ }T{SS}U{TT}V{UU}W{VV}WVS\Z\Y\X\WEWV\Y\X\WESTUW\X\WETUW\WESUWEUW\U\TBSTW\TBTWBSW\R\Q\PFW\Q\PFSTUV\PFTUVFSUV\NAUVASTV\L\K\JGTV\K\JGSV\JGVGSTU\HDTUDSU\F\E\DHU\E\DHST\DHTHS\BZZ
Link is to a Python interpreter.
Excel, 66 bytes
=LET(r,26-ROW(1:26),x,CONCAT(CHAR(65+r)),REPT(" ",r)&RIGHT(x,r+1))
Japt -R, 15 12 11 bytes
;Båi ËiEçÃÔ
;Båi ËiEçÃÔ
;B :Uppercase alphabet
å :Cumulatively reduce by
i : Prepending
Ë :Map each element a 0-based index E
i : Prepend
Eç : Space repeated E times
à :End map
Ô :Reverse
:Implicit output joined with newlines
Python 3, 71 69 bytes
for i in range(26):print(' '*(25-i)+'ZYXWVUTSRQPONMLKJIHGFEDCBA'[i:])
Rockstar, 101 bytes
X's26
while X
O's""
let Y be X
while Y
cast Y+64 into L
let O be+L
let Y be-1
let X be-1
say " "*X+O
Try it here (Code will need to be pasted in)
Pyth, 21 bytes
=_r1GV26
+*\ -25NG=tG
Basically, it sets G to ZYXWVUTSRQPONMLKJIHGFEDCBA, and next prints space repeated some amount of times and G, then removes the first letter of G.
Perl 5 + -p, 37 bytes
}{$\=$"x$-++.($a=$_.$a).$/.$\for A..Z
Explanation
Since -p is being used with no input, the leading }{ is to break out of the implicit while(<STDIN>){ that's added. This builds the string, in reverse, into $\ which is implicitly output after any content that is printed. for each char in A..Z, $\ is set to $- (which starts as 0 and is post-incremented for the next loop) $"s (which is the record separator and is initialised to space) to indent the string, concatenated with $a (which is prepended with $_, the current letter from the for loop), followed by $/ (the line terminator, defaults to "\n") and the existing contents of $\.
Perl 5 + -M5.10.0, 37 bytes
$#@-=say$"x$#@,reverse@@for\(@@=A..Z)
Explanation
This approach outputs the string in order directly. for each char in the reference (\(...)) to @@ (which is set to A..Z), this runs the loop once for each letter, @@'s final index is decremented by the result of outputting (say, includes a final newline) $" (space) 'the final index of @@ times', followed by the reverse of @@. Using the return from say as the decrement means that the output happens before the final index is removed avoiding the need to add another entry to the list. So in the first iteration this outputs 25 spaces and Z to A, then 24 spaces and Y to A ... then 1 space and BA and 0 spaces and A.
I feel like it should be possible to remove some syntax here. I played around with a way to define a list that shrinks but doesn't stop the loop halfway through and the \(...) seems to do just that, whereas [...] is seen as one list entry instead. Also trying to find a non-word character that works with the $#_ notation was trickier than I'd hoped, @; - my usual go-to results in evaluation of $# (which is removed).
Jelly, 12 bytes
ØAµ⁶ṁḊ;ṚµƤṚY
ØAµ⁶ṁḊ;ṚµƤṚY Main Link
ØA "ABC...XYZ"
Ƥ For each prefix,
µ⁶ṁḊ;Ṛµ Monadic Link
⁶ ' '
ṁ (with automatic repetition) molded to the shape of
Ḋ All but the first letter of the input (repeat - 1)
; With the input appended to it
Ṛ reversed
Y Join on newlines
Ṛ Flip upside down
-3 bytes thanks to miles
05AB1E, 16 bytes
₂F₂N-D<ð×?Aus£R,
₂F # for N in [0, 1, 2, ..., 25]:
₂N-D<ð×? # print 25 - N spaces with no trailing newline
Aus£R, # print the first 26 - N letters of the uppercase alphabet, reversed
# (implicit) exit for loop
Forth (gforth), 54 bytes
: f for i spaces i for i 65 + emit next cr next ;
25 f
How it works
: f ( n -- ) \ Print n+1 lines of searchlight.
for \ loop from n to 0 inclusive [i]
i spaces \ print i spaces
i for \ loop from i to 0 inclusive [j];
\ in Forth, the innermost loop count is always i
i 65 + emit \ print a char whose charcode is j + 65
next \ end inner loop
cr \ print a newline
next ; \ end outer loop
25 f \ push 25 and call f
Just started fiddling with Forth. Unlike the golfing tip says, it looks like n for .. next loop is the shortest for simple decreasing loops and n1 n0 do .. loop for increasing loops. The recursive call word recurse or recursive is way too verbose, and it still costs at least an if .. then.
Whitespace, 163 bytes
(s = space, t = tab, l = linefeed)
sssttstsl push 26 For x = 26 times
lssl start: ""
sls dup (Stack: [26, 26]) For y = x times
lsssl spaces:
ssstl push 1
tsst sub decrement space counter
sls dup
ltstl jz end_spaces if space counter > 0
ssstsssssl push 32
tlss outchar print space
lslsl jmp spaces
lsstl end_spaces: next y
sll drop drop y
sls dup (Stack: [26, 26])
lssssl letters:
sls dup for y = x to 0
ssstssssssl push "@"
tsss add (Stack: [26, 26, "Z"]) add y to "@" to get start letter
tlss outchar print that letter
ssstl push 1
tsst sub decrement y
sls dup
ltsstl jz end_letters
lslssl jmp letters next y
lssstl end_letters:
sll drop drop y
ssstl push 1
tsst sub decrement x
sls dup
ltsttl jz end
ssststsl push 10
tlss outchar print newline
lsll jmp start next x
Ruby, 58 bytes
Not the best answer for Ruby, but still good enough to get second place out of three entries lol. I just wanted to try a regex-based solution.
s=' '*26+[*?A..?[].reverse*''
puts s while s.sub!(/ \S/){}
Poetic, 601 bytes
one night i camped a bit
throughout all the forest now
the sweet sights
i saw giant things
i saw little small things
here i am
seated around all my trees i saw
i sleep
i sle-e-p
sleep in a cabin
i am sleep-y
i sleep a bit
i awaken in bed
i stand
i walk
i am ready
i saw a vision of a dragon
i am fooled
i know i am
should i f-ight
i f-light
i did f-light
i did a flight
go away,i do imply
i*m afraid
i run
i leave
i flee
i am timid
i*m just a person,not toughie-tough-guy
no,never
i*m waste
i am stupid
a quitter i was
i am stupid
i*m turning around
i do not appreciate camping
i cry
i am crying
no
no
Poetic is an esolang I created in 2018 for a class project, and it is a brainfuck derivative in which the lengths of words correspond to brainfuck commands (and the +, -, >, and < commands each have 1-digit arguments).
The fact that only word-length dictates the commands means that I technically could have created a program entirely composed of non-words (i.e. the letter X as many times as needed, with spaces in between words), but I wanted to make an interesting free-verse poem out of it while not adding any unnecessary bytes.
If you want to try it online (which is half the point of the class project in the first place), check out my online interpreter!
Dyalog APL, 34 23 21 bytesSBCS
↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26
Thanks to Adám for the help!
Explanation:
↑{(1-2×⍵)↑⌽⍵↑⎕A}¨⌽⍳26
⍳26 ⍝ 1..26
⌽ ⍝ Reverse, 26..1
{ }¨ ⍝ For each in this range. Iteration: ⍵
↑ ⍝ Take...
⍵ ⍝ ...⍵ elements...
⎕A ⍝ ...from the alphabet
⌽ ⍝ Reverse
↑ ⍝ Pad with spaces...
(1-2×⍵) ⍝ ...(1 - 2*current iteration) elements
↑ ⍝ Format
K4, 22 bytes
Solution:
,/'(1_')\0 25_|51$.Q.A
Explanation:
Generate two lists and reduce each until they are empty.
,/'(1_')\0 25_|51$.Q.A / the solution
.Q.A / A..Z
51$ / pad to 51 chars
| / reverse it
0 25_ / cut (_) at indices 0 and 25
( )\ / perform this along
1_' / drop (_) first from each (') list
,/' / flatten (,/) each (')
Bonus:
Another 22 byte solution:
,/'(1_')\(25#$`;|.Q.A)
C# (.NET Core), 133 114 bytes
var S="";for(int I=26;I-->0;){var C='@';for(;C++<I+64;)S+=" ";for(;C>'@';)S+=C--;S+="\n";}System.Console.Write(S);
var S=""; // Initialize the return string
for(int I=26;I-->0;){ // For all 26 rows (with I as the space count)
var C='@'; // Initializing C with the char '@' which is one under 'A'
for(;C++<I+64;) // For all spaces needed and sets the char one up ('@' -> 'A', 'A' -> 'B')
S+=" "; // Add a space to the string
for(;C>'@';) // For all characters which are needed from the char countet above up down to 'A'
S+=C; // Add the char to the string
S+="\n"; // Add a new line to the string
}
System.Console.Write(S); // Output the string
T-SQL, 115 bytes
DECLARE @ VARCHAR(51)=SPACE(25)+'ZYXWVUTSRQPONMLKJIHGFEDCBA'a:PRINT @
SET @=STUFF(@,len(@)/2,2,'')IF len(@)>0GOTO a
Shorter to just hard-code the initial string, then I used STUFF() to snip out two characters from the middle each loop.
I can save 3 bytes by using a CHAR(51) instead of a VARCHAR(51), but that prints full-width trailing spaces for all rows, which don't appear to be allowed.
Stax, 13 9 bytes
á*↔?[O╒v4
Run and debug it at staxlang.xyz!
Unpacked (15 bytes) and explanation
VAr|]mc%Hv)
VAr Uppercase alphabet, reversed
|] List of suffixes
m Map rest of program over array, printing each element with a linefeed:
c Copy top of stack
% Length
Hv Double and decrement
) Pad string on left with spaces to the specified length
I think that I stupidly confused VAr|]mc%Hv|z SHOULD work for 10 bytes (once packed), but what looks to me like a bug kills that solution.|z with ) there. Thanks @recursive for pointing that out (and saving even another byte)!
Swift, 118 bytes
var s="";for i in 0..<26{for _ in 0..<25-i{s+=" "};for j in 0..<26-i{s+="\(UnicodeScalar(90-i-j)!)"};s+="\n"};print(s)
Prettyfied:
var s = ""
for i in 0 ..< 26 {
for _ in 0 ..< 25 - i {
s += " "
}
for j in 0 ..< 26 - i {
s += "\(UnicodeScalar(90 - i - j)!)"
}
s += "\n"
}
print(s)
Common Lisp, 84 82 bytes
(dotimes(i 26)(format t"~v@{ ~}~a
"(- 25 i)(subseq"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))
Two bytes less thanks to @Ascii-only!
SmileBASIC 3, 67 64 bytes
-3 bytes from @12Me21 using the -I trick
Unfortunately the console is one character too narrow to fit the first line without wrapping the last character. Oh well.
FOR I=-25TO.?" "*-I+RIGHT$(@ZYXWVUTSRQPONMLKJIHGFEDCBA,-I+1)NEXT
Emojicode, 156 bytes
🏁🍇🍦a🔤 ZYXWVUTSRQPONMLKJIHGFEDCBA🔤🍮i 0🔁◀i 26🍇😀🍪🔪a i➖25 i🔪a➕i 25🐔a🍪🍮i➕i 1🍉🍉
Explanation:
🏁🍇 👴 start program
🍦a🔤 ZYXWVUTSRQPONMLKJIHGFEDCBA🔤 👴 big ol string
🍮i 0 👴 declare loop variable
🔁◀i 26🍇 👴 loop 26 times
😀🍪 👴 print concatenated string
🔪a i➖25 i 👴 number of spaces
🔪a➕i 25🐔a🍪 👴 reverse alphabet minus last letter
🍮i➕i 1 👴 increment loop variable
🍉 👴 end loop
🍉 👴 end program
Rust, 87 bytes
fn main(){for i in 0..26{println!("{:>1$}",&"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i..],51-2*i)}}
With Spaces and Indentation
fn main() {
for i in 0..26 {
println!("{:>1$}", &"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i..], 51-2*i)
}
}
SNOBOL4 (CSNOBOL4), 82 bytes
U =REVERSE(&UCASE)
O OUTPUT =DUPL(' ',SIZE(U) - 1) U
U LEN(1) REM . U :S(O)
END
Finally got around to a SNOBOL answer for this challenge. Always prints with a trailing newline.
Python 3, 71 bytes
for x in range(26):print(' '*(25-x),*map(chr,range(90-x,64,-1)),sep='')
Go, 127 Bytes
package main;import."strings";func main(){for i:=26;i>0;i--{print("\n",Repeat(" ",i-1));for j:=i;j>0;j--{print(string(j+64))}}}
This prints with a leading newline.
Ungolfed and readable
package main
import . "strings"
func main(){
for i := 26; i > 0; i-- {
print("\n", Repeat(" ", i-1))
for j := i; j > 0; j-- {
print(string(j + 64))
}
}
}
PHP, 113 Bytes
Code, recursive function
function f($s=0){echo ($s<26)?str_pad("", $s)
.implode(array_reverse(range(chr(65), chr(65+$s))))."
".f($s+1):"";}
Explanation
function f($s=0){
echo ($s<26)? #it stops at the 26 letter
str_pad("", $s) #padding whitespace
.implode(array_reverse(range(chr(65), chr(65+$s))))
#implode the range of letters,
#yes, range works with characters too
#reverse the array because it always starts with A
." #concatenate a linebreak
".f($s+1):""; #calling for the next letter
}
Canvas, 6 bytes
Z[↔]R⇵
Explanation (characters have been changed to their ASCII forms to look monospace):
Z push the uppercase alphabet
[ ] map over prefixes
↔ reverse horizontally
R pad each line with the line number spaces
⇵ and reverse the whole thing vertically
Visual Basic .NET (Mono), 134 bytes
Module M
Sub Main
Dim S,I,J
For I=0To 25
S=Space(25-I)
For J=0To 25-I
S+=Chr(90-I-J)
Next
Console.WriteLine(S)
Next
End Sub
End Module
Yabasic, 79 bytes
Another BASIC answer for Ya.
For I=0To 25
For J=I To 25
?" ";
Next
For K=0To 25-I
?Chr$(90-I-K);
Next
?
Next
MY-BASIC, 100 bytes
Anonymous function that takes no input and outputs to the console
For I=0 To 25
For J=I To 25
Print" "
Next
For K=0 To 25-I
Print Left(Chr(90-I-K),1)
Next
Print;
Next
uBASIC, 74 bytes
That pesky Chr$ function sure does like to add extra spaces
0ForI=0To25:?Tab(25-I);:ForJ=0To25-I:?Left$(Chr$(90-I-J),1);:NextJ:?:NextI
Kotlin, 87 71 bytes
Submission
{(0..25).map{(it..25).map{print(" ")
it}.map{print('Z'-it)}
println()}}
Beautified
{
// For it from 25 to 0
(0..25).map {
// Print that number of spaces
// Print the alphabet backwards from that letter
(it..25).map { print(" ")
it}.map { print('Z' - it) }
// Newline
println()
}
}
Test
var f:()->Unit =
{(0..25).map{(it..25).map{print(" ")
it}.map{print('Z'-it)}
println()}}
fun main(args: Array<String>) {
f()
}
Implicit, 24 23 22 19 bytes
À¦\^(-(1ß-);%\1^ß1ö
À « push alphabet »;
¦ « swap case »;
\ « reverse »;
^ « push length »;
( « do »;
- « decrement string length »;
(1..) « while top of stack truthy »;
ß « print space »;
- « decrement string length »;
; « pop string length »;
% « print string »;
\1 « knock first character off string »;
^ « push length »;
ß1 « print newline »;
ö « exit without implicit output if top of stack falsy »;
« implicit infinite loop »;
Acc!!, 113 bytes
26
Count i while i-_ {
Count b while b-25+i {
Write 32
}
Count t while t-_+i {
Write 90-t-i
}
Write 10
}
J, 21 bytes
({.~1-2*#)\.u:90-i.26
original version
(,~' '#~<:@#)\.|.26$65|.a.
26$65|.a.get A - Z|.reverse them\.take successive prefixes from the right side(,~' '#~<:@#)append to each one (,~) a number of spaces equal to the length of the prefix minus 1 (<:@#)
Vim, 43 keystrokes
:h<_<CR>jjYZZPVgUxjpqqy$-i <Esc>lpl"aDYPD"ap+q25@q
You can see it in action in this GIF made using Lynn's python script
Haskell, 52 48 53 bytes
do x<-scanr(:)[]['Z','Y'..'A'];tail$(' '<$x)++x++"\n"
q/kdb+, 32 31 bytes
Solution:
raze@/:(1_')\[(25#" ";(|).Q.A)]
Example:
q)raze@/:(1_')\[(25#" ";(|).Q.A)]
" ZYXWVUTSRQPONMLKJIHGFEDCBA"
" YXWVUTSRQPONMLKJIHGFEDCBA"
" XWVUTSRQPONMLKJIHGFEDCBA"
" WVUTSRQPONMLKJIHGFEDCBA"
" VUTSRQPONMLKJIHGFEDCBA"
" UTSRQPONMLKJIHGFEDCBA"
" TSRQPONMLKJIHGFEDCBA"
" SRQPONMLKJIHGFEDCBA"
" RQPONMLKJIHGFEDCBA"
" QPONMLKJIHGFEDCBA"
" PONMLKJIHGFEDCBA"
" ONMLKJIHGFEDCBA"
" NMLKJIHGFEDCBA"
" MLKJIHGFEDCBA"
" LKJIHGFEDCBA"
" KJIHGFEDCBA"
" JIHGFEDCBA"
" IHGFEDCBA"
" HGFEDCBA"
" GFEDCBA"
" FEDCBA"
" EDCBA"
" DCBA"
" CBA"
" BA"
,"A"
""
Explanation:
Create two lists, 1 with 25 spaces, 1 with the reversed alphabet, then drop the first item from each list and join together. Use converge \ to terminate when the output matches previous output (hence this results in a trailing empty line):
raze each (1_')\[(25#" ";reverse .Q.A)] / ungolfed solution
( ; ) / two item list
25#" " / 25 take " ", whitespace 25 long
reverse .Q.A / .Q.A is uppercase alphabet A..Z, reverse reverses, so Z..A
( )\[ ] / converge running left function with right arguments
1_' / 1 drop (_) each (') removes first item from each sublist and returns result (2 lists)
raze each / raze reduces a list of lists, so we reduce each sublist of 2 lists to a single list
Python 2, 86 83 bytes
for x in range(25,-1,-1):print(" "*x)+"".join([chr(y+65)for y in range(x+1)][::-1])
Thanks to Stephen for the 3 extra bytes.
VBA, 65 Bytes
Anonymous VBE immediate window function that takes no input and outputs to the VBE immediate window
For i=0To 25:?Spc(25-i);:For j=0To 25-i:?Chr(90-j-i);:Next:?:Next
Naïve Version, 68 Bytes
For i=0To 25:?Spc(25-i)Right("ZYXWVUTSRQPONMLKJIHGFEDCBA",26-i):Next
Python 3, 69 bytes
for i in range(26):print(" "*(25-i)+"ZYXWVUTSRQPONMLKJIHGFEDCBA"[i:])
This is my first challenge. I hope i've done this right.
Edit: Had a 26 where a 25 should have been.
Java, 196 134 bytes
Yes, this has no chance of winning overall, but it helps to re-familiarize myself with the language. Any improvements are welcome, but know I have not yet had time to read the Tips or Golfing in Java.
public class A{public static void main(String[]a){for(int i=0;i<26;i++){for(int j=0;j<25-i;j++)System.out.print(" ");for(char c=(char)(90-i);c>=65;c--)System.out.print(c);System.out.println();}}}
Thanks to JollyJoker for suggesting improvements. I won't get a chance to investigate lambdas for this one, but I'll remember it for the future. This is as short as I'll make this one. Eclipse kept complaining when I changed all ints to chars, so I'll look into that some more.
String a(){String r="";for(int i=0;i<26;i++){for(int j=0;j<25-i;j++)r+=" ";for(char c=(char)('Z'-i);c>=65;c--)r+=c;r+="\n";}return r;}
Ungolfed:
public class A {
public static void main(String[] args) {
for (int i = 0; i < 26; i++) {
for (int j = 0; j < 25 - i; j++)
System.out.print(" ");
for (char c = (char)(90 - i); c> = 65; c--)
System.out.print(c);
System.out.println();
}
}
}
String a() {
String r = "";
for (int i = 0; i < 26; i++) {
for (int j = 0; j < 25 - i; j++)
r += " ";
for (char c = (char)('Z'-i); c >= 65; c--)
r += c; r+= "\n";
}
return r;
}
///, 105 97 bytes
/:/\\\\*//#/:Z:Y:X:W:V:U:T:S:R:Q:P:O:N:M:L:K:J:I:H:G:F:E:D:C:B:A//\\*/\/\/_____#
\/ //_/ //*#
Explanation
/// only knows one command, /<pattern>/<substitution>/<text> replaces all occurrences of <pattern> in <text> with <substitution>. Additionally \ can be used to escape characters.
Shortened code for simplicity:
/:/\\\\*//#/:E:D:C:B:A//\\*/\/\/__#
\/ //_/ //*#
The first command /:/\\\\*/ replaces : with \\* in the subsequent code. This gives:
/#/\\*E\\*D\\*C\\*B\\*A//\\*/\/\/__#
\/ //_/ //*#
Then /#/\\*E\\*D\\*C\\*B\\*A/ replaces # with \*E\*D\*C\*B\*A:
/\\*/\/\/__\*E\*D\*C\*B\*A
\/ //_/ //*\*E\*D\*C\*B\*A
Then /\\*/\/\/__\*E\*D\*C\*B\*A<newline>\/ / replaces \* with //__*E*D*C*B*A<newline>/:
/_/ //*//__*E*D*C*B*A
/ E//__*E*D*C*B*A
/ D//__*E*D*C*B*A
/ C//__*E*D*C*B*A
/ B//__*E*D*C*B*A
/ A
Notice: I had to use \* for replacement. Since * is also part of the substitution, it would generate an infinite loop if I only replace *.
Then command /_/ / replaces _ with spaces, and /*// deletes all *:
EDCBA
/ E// EDCBA
/ D// EDCBA
/ C// EDCBA
/ B// EDCBA
/ A
The next command /#// replaces # by nothing. Since there is no # in the code, it does nothing. This is just here to remove the two leadings // from the beginning of the code. This leaves
EDCBA
/ E// EDCBA
/ D// EDCBA
/ C// EDCBA
/ B// EDCBA
/
Then the command / E// removes <space>E, so this will leave the code
EDCBA
DCBA
/ D// DCBA
/ C// DCBA
/ B// DCBA
/
Similar / D// removes <space>D:
EDCBA
DCBA
CBA
/ C// CBA
/ B// CBA
/
/ C//:
EDCBA
DCBA
CBA
BA
/ B// BA
/
/ B//:
EDCBA
DCBA
CBA
BA
A
/
And the last command is incomplete, so it does nothing:
EDCBA
DCBA
CBA
BA
A
C++, 146 142 141 140 137 133 bytes
-4 bytes thanks to MD XF
-4 bytes thanks to Zacharý
#include<iostream>
#define F for(i=26-g;i;--i)std::cout<<
void f(){for(int g=1,i;g<27;g+=2){F ' ';--g;F char(64+i);std::cout<<'\n';}}
Java (OpenJDK 8), 105 bytes
z->{for(int i=0;i<26;)System.out.printf("%"+(51-i*2)+"s%n","ZYXWVUTSRQPONMLKJIHGFEDCBA".substring(i++));}
Ruby, 60 bytes
I couldn't beat @Snack's answer, but here are some solutions that I found interesting:
25.downto 0{|i|$><<" "*i;i.downto 0{|e|$><<(65+e).chr};puts}
I'm also particularly entertained by calculating the spaces this way and was saddened that it wasn't shorter:
z="";(?A..?Z).each{|e| (?A..e).each{|k| z+=k}; z+=" "*(z.size**0.5-1)+?\n};puts z.reverse
At least it's the only answer that uses a square root!
PHP (63 58 55 bytes)
This is possibly my favorite strange corner of PHP, a corner which it inherits from Perl:
for($c=A;$c!=AA;$q="$s$z
$q",$s.=" ")$z=$c++.$z;echo$q;
This outputs the trailing newline, as explicitly permitted. This can be run in php -r to save the opening <?php needed to put this in a file.
Explanation: when a variable containing the string 'A' is incremented in PHP, it becomes 'B' and then 'C' and so on up until 'Z' becomes 'AA'. There is no digit before 'A' to start with in this madcap algebra, and the decrement operator does not undo it, so we save the incrementally reversed alphabet to $z (which defaults to NULL which when it gets concatenated with a string behaves like the empty string -- the same happens with $s and $q). Whitespace is accumulated in $s and the whole string is accumulated backwards in variable $q which means we have to echo it at the end.
Thanks to Titus for golfing off my curly braces and telling me that I don't need to take a penalty for inline-evaluation flags like -r.
vim, 46 bytes
:set nf=alpha
25a <ESC>aZ<ESC>qaylp<CTRL+X>q24@aqayyphxxq24@a
Ungolfed:
:set nf=alpha " add letters to the set of number formats used by CTRL+A, CTRL+X
25a <ESC>aZ<ESC> " add the leading spaces and the Z
qaylp<CTRL+X>q " record macro to copy and decrement the last letter, and
24@a " run 24 times
qayyphxxq " record macro to copy/paste the last line, and delete the last space and first letter.
24@a " run 24 times.
<ESC> and <CTRL+X> are 0x1B and 0x18 respectively.
Java, 206 bytes
public class Main{public static void main(String[]args){int i,j,k,l=90;for(k=26;k>=0;k--){for(i=k-1;i>0;i--){System.out.print(" ");}for(j=l;j>=65;j--){System.out.print((char)j);}l--;System.out.println();}}}
Pyke, 8 bytes
G_.<XFo}h-
- o = 0
G_ - reversed(alphabet)
.< - suffixes(^)
XF - for i in ^:
o - o++
} - ^ * 2
h - ^ + 1
- - i.lpad(" ", ^)
- for i in reversed(^):
- print i
I can see the right language doing this in 6 bytes if they had a builtin for prepend n spaces to string as well as what Pyke does
AWK, 76 bytes
{for(;++j<27;)printf"%"53-2*j"s\n",substr("ZYXWVUTSRQPONMLKJIHGFEDCBA",++z)}
Tried 3-4 different versions, including double for loop, this is the fewest bytes I could come up with.
Not sure if I should add 1 byte since it does require some input to produce output.
sed 4.2.2 + Bash, 50 bytes
s/^/printf %25s;printf %s {Z..A}/e
:
p
s/ \S//
t
d
Bash + sed 4.2.2, 51 bytes
printf %s {Z..A}|sed 'h
s/./ /g
G
:
s/ [^ ]//p
t
d'
Building on @DigitalTrauma's answer.
Python, 83 bytes
[print(' '*i+''.join([chr(64+i)for i in range(i+1,0,-1)]))for i in range(25,-1,-1)]
My first answer on codegolf :)
Pyth, 14 bytes
-2 from dave and ven thanks guys
V_UG+*dNrG1=PG
Explanation coming when I figure it out wake up.
Pyth, 16 bytes
V26p*-25Nd>_rG1N
Explanation:
V26 26 times, could've written lG, but it's the same
p*-25Nd Print without newline: 25-index spaces (could've used + instead of p but it's simpler to explain)
>_rG1N Implicit print with newline: The last index characters of the reverse uppercase alphabet
While you're here, here's Artemis's first answer ported into Pyth:
Pyth, 21 20 bytes (non-competing)
J26W=tJ+*dJ>_rG1-25J
An explanation for Artemis's answer:
J26 Set J to 26
W While...
=tJ Decrement J (J-=1)
+*dJ J spaces plus...
>_rG1-25J The last 25-index characters of the reverse uppercase alphabet
I should stop writing these on my phone
Retina, 38 bytes
25$* Z
{-2=`
$'
}T`L`_L`.$
;{:G`
\w
Explanation
25$* Z
Initialise the working string to 25 spaces and a single Z.
{-2=`
$'
}T`L`_L`.$
The usual approach for generating the alphabet: repeatedly duplicate the last letter, then decrement that letter with a transliteration, removing As instead of decrementing them further. That means once we get to A, the second stage will delete the letter which was added by the first stage, so there won't be any net change and the loop stops. That gives us the first line of the output.
;{:G`
\w
Now we really just repeatedly print the current line and the drop a space followed by a letter. The construction is slightly weird due to how loops and printing works in Retina. We need to print before we drop the letter, which requires a separate stage that otherwise doesn't do anything, and we also need to disable the implicit printing at the end of the program.
C, 82 characters
char*a="ZYXWVUTSRQPONMLKJIHGFEDCBA\n",i=54;main(){while(i)printf("%*s",i-=2,a++);}
Works for any character coding, by embedding the full alphabet. We print subsequent trailing substrings in a field twice as wide as required, to get the leading spaces.
I had hoped to be able to reduce it further with while(printf());, but couldn't arrange for the return value to reach zero at the right point.
Bash + coreutils, 64 bytes
printf '%s' {Z..A}|sed 'h;s/./ /g;G;s/ \n//;p;:a;s/ \b.//p;ta;Q'
Octave, 53 49 46 45 bytes
1 byte removed thanks to @Sanchises
for k=25:-1:0,disp([blanks(k) 65+k:-1:65])end
Twig, 93 bytes
Twig is a template language developed to be used in PHP, which is similar to Smarty, Django or Jinja.
{%for a in "Z".."A"%}{{("%"~(26-loop.index)~"s%s")|format(f,range(a,"A")|join())}}
{%endfor%}
This code relies in the fact that the environment option strict_variables defaults to false. Otherwise, it will break.
Try it on https://twigfiddle.com/9umogr (check the raw result).
If you want to copy-paste the code, make sure that you disable strict_variables, since the website sets that to true.
SimpleTemplate, 102 bytes
This is just a very straight-forward implementation, nothing fancy.
{@setV 25}{@forfrom"Z"to"A"}{@callstr_repeat intoX" ",V}{@callrange intoZ _,"A"}{@echolX,Z}{@incby-1V}
Try it on http://sandbox.onlinephpfunctions.com/code/a31f7d1b8532385cc135cc1bf64e05d702ebcce4
Ungolded:
{@set spaces 25}
{@for i from "Z" to "A"}
{@call str_repeat into padding " ", spaces}
{@call range into letters i, "A"}
{@echo EOL, padding, letters}
{@inc by -1 spaces}
{@/}
Should be almost self-explainatory
brainfuck, 105 bytes
++++++++[>+>+++++++++++>++++>+++<<<<-]>++>++>>++[[->+>+<<]>-[-<<.>>]>[-<<<<.->>>+>]<-[-<+<<+>>>]<<<<.>>>]
Minified and formatted:
++++++++[>+>+++
++++++++>++++>+
++<<<<-]>++>++>
>++[[->+>+<<]>-
[-<<.>>]>[-<<<<
.->>>+>]<-[-<+<
<+>>>]<<<<.>>>]
Readable version:
[
pre-initialize the tape with the values 10 90 32 >26<
C_NEWLINE: 10
V_ALPHA: 90
C_SPACE: 32
V_COUNTER: 26
AS:
10 = 8 * 1 + 2
90 = 8 * 11 + 2
32 = 8 * 4 + 0
26 = 8 * 3 + 2
]
8 ++++++++ [
* 1 >+
* 11 >+++++++++++
* 4 >++++
* 3 >+++
<<<<-]
PLUS 2 >++
PLUS 2 >++
PLUS 0 >
PLUS 2 >++
UNTIL V_COUNTER == 0 [
COPY V_COUNTER to RIGHT and RIGHT_RIGHT
[->+>+<<]
TAPE: 10 V_ALPHA 32 >0< V_COUNTER_R V_COUNTER_RR
V_COUNTER_R SUB 1 TIMES: >-[-
PRINT C_SPACE <<.
>>]
TAPE: 10 V_ALPHA 32 0 >0< V_COUNTER_RR
V_COUNTER_RR TIMES: >[-
PRINT V_ALPHA <<<<.
DECREMENT V_ALPHA -
INCREMENT V_COUNTER_R >>>+
>]
TAPE: 10 V_ALPHA 32 0 V_COUNTER_R(26) >0<
V_COUNTER_R SUB 1 TIMES: <-[-
INCREMENT V_COUNTER <+
INCREMENT V_ALPHA <<+
>>>]
PRINT C_NEWLINE <<<<.
>>>]
Javascript, 82 bytes
for(i=26;i;){console.log(" ".repeat(i-1)+"ZYXVUTSRQPONMLKJIHGFEDCBA".slice(-i--))}
Cubix, 43 46 bytes
$/\;u:\s/':(!$u;:'@^!@Wu;oSU;o+<u(;;oN;(!|
Cubified
$ / \
; u :
\ s /
' : ( ! $ u ; : ' @ ^
! @ W u ; o S U ; o + <
u ( ; ; o N ; ( ! | . .
. . .
. . .
. . .
Have managed to shave a few more of this, but it was a bit more difficult than I thought. There is a substitute character after the first quote to give me 26.
'<sub>push 26 onto the stack as the base number:(!duplicate base as a counter, decrement, test for truthyuon true skip the$command and u-turn to the rightSo;upush 32, output as character, pop 32 and u-turn right onto the decrement
$on false jump the nextucommand;:'@^pop, duplicate the base number, push 64 onto stack and redirect into a torturous route$\s/:\/u;$this is the order of the steps on the top face. It boils down to swap the counter with the 64. Ends with a skip over the redirect that put it here.<+o;Uredirect to add, output character, pop, u-turn left(!decrement, test for truthy. If true starts on a path which hits the u-turn and goes back to the redirect.|(;Noon false, reflect, redundant test, redundant decrement, pop, push 10 and output character;;(u!@Wpop down to the base number, decrement, u-turn right onto truthy test, halt if false otherwise change lane onto the duplicate at the beginning. Rinse and repeat.
brainfuck, 119 bytes
>+++++[<++>>+++++<-]>+>++++[>++++++++<-]>>-[>+<---]>+++++<<<<[-[->+>.<<]>[->>>.->+<<<<]>>>.->[-<+<<<<+>>>>>]<<<<<<<.>>]
Could be golfable by better initializing the tape - there is a modulo solution that would pop 90,32,26 and 10, that would also probably leave the tape a little less fragmented.
Also could combine all three loops unto one, by juggling the index as the difference from the ASCII code 'Z', or something.
Clojure v1.8, 93 bytes
Converted Renzo's answer to Clojure.
(dotimes[i 26](prn(apply str(concat(repeat(- 25 i)" ")(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))))
Explanation
(dotimes [i 26] ...) We will print 26 lines, i is between[0, 26)
(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i) Take the string starting from position 'i'
(repeat(- 25 i)" ") Repeat the whitespaces, we start from 25 because the last line doesn't have whitespaces
(prn(apply str(concat(repeat(- 25 i)" ")(subs"ZYXWVUTSRQPONMLKJIHGFEDCBA"i)))) Concatenate the sequence of whitespaces and the string in order to have the desired effect with 'str' next
Perl 6, 37 bytes
Saved 9 bytes thanks to @Massa.
say " "x$_,chrs $_+65...65 for 25...0
Explanation: 25...0 is a range from 25 to 0 (as expected). We iterate over that range, saying (= printing with newline) that many spaces and the string of characters that have ASCII codes (chrs) from 65 + that number ($_+65...65).
Perl 6, 57 bytes
.put for (' 'Xx(25...0))Z~(('Z'...'A') »...»'A')».join
Expanded:
.put # print with trailing newline
for # for each of the following
(
' '
Xx # cross using string repetition operator
( 25 ... 0 ) # from 25 down to 0
)
Z~ # zip using string concatenation
(
( 'Z' ... 'A' ) # descending sequence of starting values
»...» # combine those into sequences each with an end value of 'A'
'A'
)».join # combine each of the sub sequences into strings
Octave, 38 bytes (or 46 bytes in tio)
flip([spdiags(hankel(90:-1:65)) '']')'
Generates the correct output at least on windows installation of Octave, but in tio to be correctly shown the character 0 should be replace by space:
[max(32,flip(spdiags(hankel(90:-1:65))')') '']
VB, 167 bytes
i = 26
For a = i To 1 Step -1
For j = a To 1 Step -1
c = c + " "
b = b + Chr(64 + j)
Next
d = d & c & b & vbNewLine
c = ""
b = ""
Next
msgbox d
first time to participate but i'm not competing to everyone, just myself. lol
QBIC, 48 bytes
[26|Q=Q+chr$(a+64)][26,1,-1|?space$(b)+_s_fQ|,-b
Explanation
[26| FOR a = 1; a <= 26; a++
Q=Q+chr$(a+64) Add to Q$ a chr() being a+64 (A-Z in succession)
] NEXT (at the end of the loop, Q$ is ABC...XYZ)
[26,1,-1| FOR b = 26; b >= 1; b--
?space$(b) PRINT b spaces,
+_s and a substring of
_fQ| Q$ reversed,
,-b taking b characters from the right
C# (.NET Core), 87 + 18 bytes
_=>new int[26].Select((x,i)=>"ZYXWVUTSRQPONMLKJIHGFEDCBA".Substring(i).PadLeft(51-2*i))
Also included in byte count:
using System.Linq;
This outputs a collection of strings (for each line).
Explanation:
_ => // A function that takes one argument (unused)
new int[26]. // Create new collection size 26
Select((x, i) => // Replace every member with
"ZYXWVUTSRQPONMLKJIHGFEDCBA" // Our alphabet
.Substring(i) // Take it's part based on line number
.PadLeft(51 - 2 * i) // Add spaces to the left
)
Here's non-kolmogorov version (for any string) - 76 + 18 bytes:
a=>new int[a.Length].Select((x,i)=>a.Substring(i).PadLeft(a.Length*2-1-2*i))
SpecBAS - 89 bytes
1 s=25,a$="ZYXWVUTSRQPONMLKJIHGFEDCBA"
2 ?" "*s;a$
3 a$=a$(2 TO),s-=1
4 IF s>0 THEN 2
5 ?a$
Bit of string splicing, rinse and repeat
K (oK), 31 27 bytes
Solution:
{`c$(x#32),65+|!x+1}@/:|!26
Explanation:
Iterate over the list of 25..0, each iteration create the reverse alphabet joined with x many spaces:
{`c$(x#32),65+|!x+1}@/:|!26 / solution
!26 / til 26 (0..25)
| / reverse (25..0)
@/: / each (25, 24, 23...)
{ } / lambda function
x+1 / increment x (25->26)
! / til x (0..26)
| / reverse
65+ / add 65, 0+65 = ASCII "A"
, / join
(x#32) / x take 32 (e.g 32, x many times)
`c$ / cast everything to characters
C (gcc), 75 72 bytes
-3 bytes thanks to Steadybox
i=27;main(j){for(;--i;)for(printf("\n%*c",j=i,64+i);--j;putchar(64+j));}
RProgN 2, 17 bytes
AL«]' '*\A\ùi.‹»;
Explained
AL«]' '*\A\ùi.‹»;
AL # Length of the Alphabet, 26.
« »; # For each, numbers 1 through 26 inclusive.
] # Duplicate the index eg. (5, 5)
' '* # Repeat ' ' by the index. (5, ' ')
\ # Flip the top of the stack, (' ', 5)
A\ # Push the alphabet under the top. (' ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 5)
ù # Get the first n characters. (' ', 'ABCDE')
i # Reverse the top of the stack. (' ', 'EDCBA')
. # Concatenate. (' EDCBA')
‹ # Rotate left, to remove the extra space. (' EDCBA ')
This leaves each result on the stack, and RProgN2 implicitely prints the stack upside down, which conveniently gives us our result.
Mathematica, 79 73 bytes
Column@(T=Table)[T[" ",26-i]<>ToUpperCase@Alphabet[][[-i;;1;;-1]],{i,26}]
or without Alphabet
Mathematica, 75 66 bytes
Column@Array[Table[" ",26-#]<>Reverse@CharacterRange[65,91-#]&,26]
thanks @JungHwanMin for golfing more both of my answers
V, 13, 11 bytes
¬ZAòY>HGpxl
Hexdump:
00000000: ac5a 41f2 593e 4847 7078 6c .ZA.Y>HGpxl
Written from my phone :P.
¬ZA " Insert the alphabet backwards
ò " Recursively:
Y " Yank this current line
>H " Add one space to every line
G " Move to the last line in the buffer
p " Paste the line we yanked
x " Delete one character
l " Move one character to the right, which will throw an error on
" the last time through, breaking the loop
JavaScript, 75 74 bytes
1 byte saved thanks to Rick Hitchcock
f=(a=65,b='',c)=>a>90?'':f(a+1,b+' ',c=String.fromCharCode(a)+[c])+`
`+b+c
Charcoal, 19 11 bytes
-8 bytes thanks to ASCII-only.
F²⁶«P⮌…α⊕ι↗
Try it online! Link is to verbose version.
PHP, 82 bytes
$l=strlen($s=$argv[1]);while($l)echo strrev(str_pad(substr($s,0,$l),$l+$l--))."
";
Called with ABCDEFGHIJKLMNOPQRSTUVWXYZ as an argument.
Do I get bonus points because it produces the desired effect with any string? :P
05AB1E, 7 bytes
Code:
₂žp.s1Λ
Uses the 05AB1E encoding. Try it online!
Explanation
žp.s # Get the suffixes of ZYX...CBA
Λ # Using the canvas mode, print the
₂ # first 26 elements of the array
1 # into the upper-right direction
Haskell, 53 52 bytes
f(a:b)=(b>>" ")++a:b++'\n':f b
f x=x
f['Z','Y'..'A']
How it works
f['Z','Y'..'A'] -- call f with the full backwards alphabet
f(a:b)= -- let `a` be the first char and `b` the rest. Return
(b>>" ") ++ -- replace each char in b with a space, followed by
a:b ++ -- the input string, followed by
'\n' : -- a newline, followed by
f b -- a recursive call of `f` with `b`
f x=x -- stop on an empty input string
PowerShell, 42 bytes
25..0|%{' '*$_+-join[char[]]((65+$_)..65)}
Explanation:
25..0|%{ } # Loop from 25 to 0
(65+$_)..65 # Construct a range of the specific ASCII codes
[char[]]( ) # Cast that as a character array
-join # that has been joined together into a string
' '*$_+ # Prepended with the correct amount of spaces
JavaScript (ES6), 83 77 76 bytes
f=(n=0,p='')=>n<26?f(++n,p+' ')+p+`ZYXWVUTSRQPONMLKJIHGFEDCBA
`.slice(~n):''
o.innerText = f()
<pre id=o>
Bubblegum, 85 bytes
Hexdump:
0000000: 53c0 05a2 2223 c2c3 4243 8283 0203 fcfd S..."#..BC......
0000010: 7c7d bcbd 3c3d dcdd 5c5d 9c9d 1cb9 7069 |}..<=..\]....pi
0000020: 2159 0789 ea49 524d 825a a255 12a9 8e28 !Y...IRM.Z.U...(
0000030: 5544 a821 a882 803c 5e59 3c72 3865 7088 UD.!...<^Y<r8ep.
0000040: 6315 c522 8621 82c6 47e1 21b1 e12c 280d c..".!..G.!..,(.
0000050: 2681 d811 00 &....
Python 2, 72 67 bytes
i=26
while-~i:print' '*i+''.join(map(chr,range(65,91)))[i::-1];i-=1
Pyth, 15 bytes
j_.e+*kd_rb1._G
Explanation
j_.e+*kd_rb1._G- Full program.._G- Prefixes of the lowercase alphabet..e- Enumerated map, withkas the indexes andbas the values.*kd- A space repeated a number of times equal to the current index._rb1- And the current element converted to uppercase.+- String concatenation._- Reverse.j- Join by newlines.
Python 3, 84 80 73 bytes
for i in range(25,-1,-1):print(' '*i+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i::-1])
Saved 7 bytes thanks to @Mr. Xcoder
05AB1E, 10 bytes
žpDvÐg<ú,¦
Explanations:
žpDvÐg<ú,¦
žp Push the uppercased alphabet, reversed
D Duplicate
v For each letter (we just want to loop 26 times, so we use the
already pushed alphabet for that purpose)
Ð Triplicate
g< Length of the string - 1
ú Add that number of spaces at the beginning of the string
, Print with newline
¦ Remove the 1st element of the remaining copy of the string

