Você já viu o incrível triângulo do alfabeto , a vingança do triângulo do alfabeto e agora é hora da vingança da vingança do triângulo do alfabeto!
Apresentando ...
O DIAMANTE DO ALFABETO!
Sua tarefa é produzir esse texto exato, em minúsculas / maiúsculas não importa, embora as novas linhas importem:
bcdefghijklmnopqrstuvwxyzazyxwvutsrqponmlkjihgfedcb
cdefghijklmnopqrstuvwxyzabazyxwvutsrqponmlkjihgfedc
defghijklmnopqrstuvwxyzabcbazyxwvutsrqponmlkjihgfed
efghijklmnopqrstuvwxyzabcdcbazyxwvutsrqponmlkjihgfe
fghijklmnopqrstuvwxyzabcdedcbazyxwvutsrqponmlkjihgf
ghijklmnopqrstuvwxyzabcdefedcbazyxwvutsrqponmlkjihg
hijklmnopqrstuvwxyzabcdefgfedcbazyxwvutsrqponmlkjih
ijklmnopqrstuvwxyzabcdefghgfedcbazyxwvutsrqponmlkji
jklmnopqrstuvwxyzabcdefghihgfedcbazyxwvutsrqponmlkj
klmnopqrstuvwxyzabcdefghijihgfedcbazyxwvutsrqponmlk
lmnopqrstuvwxyzabcdefghijkjihgfedcbazyxwvutsrqponml
mnopqrstuvwxyzabcdefghijklkjihgfedcbazyxwvutsrqponm
nopqrstuvwxyzabcdefghijklmlkjihgfedcbazyxwvutsrqpon
opqrstuvwxyzabcdefghijklmnmlkjihgfedcbazyxwvutsrqpo
pqrstuvwxyzabcdefghijklmnonmlkjihgfedcbazyxwvutsrqp
qrstuvwxyzabcdefghijklmnoponmlkjihgfedcbazyxwvutsrq
rstuvwxyzabcdefghijklmnopqponmlkjihgfedcbazyxwvutsr
stuvwxyzabcdefghijklmnopqrqponmlkjihgfedcbazyxwvuts
tuvwxyzabcdefghijklmnopqrsrqponmlkjihgfedcbazyxwvut
uvwxyzabcdefghijklmnopqrstsrqponmlkjihgfedcbazyxwvu
vwxyzabcdefghijklmnopqrstutsrqponmlkjihgfedcbazyxwv
wxyzabcdefghijklmnopqrstuvutsrqponmlkjihgfedcbazyxw
xyzabcdefghijklmnopqrstuvwvutsrqponmlkjihgfedcbazyx
yzabcdefghijklmnopqrstuvwxwvutsrqponmlkjihgfedcbazy
zabcdefghijklmnopqrstuvwxyxwvutsrqponmlkjihgfedcbaz
abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba
bcdefghijklmnopqrstuvwxyzazyxwvutsrqponmlkjihgfedcb
abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba
zabcdefghijklmnopqrstuvwxyxwvutsrqponmlkjihgfedcbaz
yzabcdefghijklmnopqrstuvwxwvutsrqponmlkjihgfedcbazy
xyzabcdefghijklmnopqrstuvwvutsrqponmlkjihgfedcbazyx
wxyzabcdefghijklmnopqrstuvutsrqponmlkjihgfedcbazyxw
vwxyzabcdefghijklmnopqrstutsrqponmlkjihgfedcbazyxwv
uvwxyzabcdefghijklmnopqrstsrqponmlkjihgfedcbazyxwvu
tuvwxyzabcdefghijklmnopqrsrqponmlkjihgfedcbazyxwvut
stuvwxyzabcdefghijklmnopqrqponmlkjihgfedcbazyxwvuts
rstuvwxyzabcdefghijklmnopqponmlkjihgfedcbazyxwvutsr
qrstuvwxyzabcdefghijklmnoponmlkjihgfedcbazyxwvutsrq
pqrstuvwxyzabcdefghijklmnonmlkjihgfedcbazyxwvutsrqp
opqrstuvwxyzabcdefghijklmnmlkjihgfedcbazyxwvutsrqpo
nopqrstuvwxyzabcdefghijklmlkjihgfedcbazyxwvutsrqpon
mnopqrstuvwxyzabcdefghijklkjihgfedcbazyxwvutsrqponm
lmnopqrstuvwxyzabcdefghijkjihgfedcbazyxwvutsrqponml
klmnopqrstuvwxyzabcdefghijihgfedcbazyxwvutsrqponmlk
jklmnopqrstuvwxyzabcdefghihgfedcbazyxwvutsrqponmlkj
ijklmnopqrstuvwxyzabcdefghgfedcbazyxwvutsrqponmlkji
hijklmnopqrstuvwxyzabcdefgfedcbazyxwvutsrqponmlkjih
ghijklmnopqrstuvwxyzabcdefedcbazyxwvutsrqponmlkjihg
fghijklmnopqrstuvwxyzabcdedcbazyxwvutsrqponmlkjihgf
efghijklmnopqrstuvwxyzabcdcbazyxwvutsrqponmlkjihgfe
defghijklmnopqrstuvwxyzabcbazyxwvutsrqponmlkjihgfed
cdefghijklmnopqrstuvwxyzabazyxwvutsrqponmlkjihgfedc
bcdefghijklmnopqrstuvwxyzazyxwvutsrqponmlkjihgfedcb
Este é o código-golfe, o menor número de vitórias do número anterior.
Regras:
- As brechas padrão não são permitidas.
a
deve ser o centro do diamante do alfabeto.
code-golf
string
kolmogorov-complexity
alphabet
Urna de polvo mágico
fonte
fonte
a
e o centro fossez
.<
faria isso em Pyth:.<S5 1
resultaria em[2, 3, 4, 5, 1]
. É o mesmo que.<[1 2 3 4 5)1
. Não tenho certeza para o diamante, no entanto.b
ser a letra inicial em vez dea
. É claro que mudar também é vital.Respostas:
05AB1E ,
1312 bytesExperimente online!
Explicação
fonte
A©gF®À©û})û»
é o que eu estava pensando. De maneira alguma você está fazendo errado! Eu aprendi tudo o que sei assistindo você heh. A lista global é a mesma ideia básica.Teclas Vim,
62, 60Inspirando-se na impressionante resposta vim de Lynn para ter a idéia de roubar o alfabeto dos documentos de ajuda.
Você pode assistir isso acontecer em tempo real, enquanto luto para lembrar a sequência correta de teclas!
Observe que este gif está um pouco desatualizado porque produz uma saída incorreta, e ainda não consegui regravá-lo ainda.
fonte
MATL, 14 bytes
Try it online!
fonte
PHP, 129 Bytes
fonte
syntax error, unexpected '(' on line 1
Which php version?for($f=substr;
and$f($r=join(range(a,z)),$i,26-$i))
instead of($f=substr)($r=join(range(a,z)),$i,26-$i))
to avoid the errorHaskell, 75 bytes
How it works:
fonte
C, 76 bytes
Function, to be called as below. Prints capital letters.
Simple approach, add the x and y distances from the centre of the square, plus an offset of 25 for the
a
in the middle, take modulo 26 and subract from90
, the ASCII code forZ
. Wherei%52
==0 a newline ASCII10
is printed.fonte
+25
is the same as-1
in modulo 26-1%26
in C is -1, not 25. The result is a[
in the centre instead of the expectedA
. Thanks anyway, you would have been correct in a language such as Ruby where-1%26
does equal 25.R, 71 bytes
outer
creates a matrix with the indices of the letters,letters[...]
then creates a vector with the correct letters in.cat(...,sep="",fill=53)
then prints it out with the desired formatting.fonte
fill
option forcat
. Great way of printing formatted matrices.Jelly, 13 bytes
Try it online!
Explanation
fonte
Øaṙ'JŒBŒḄY
for 10 :)ṙ1ṭ
bit. AlsoØaṙJŒBŒḄY
is fine, you don't need the quick since it vectorizes on the right to 0Jelly, 11 bytes
Explanation:
fonte
Python 2,
9685 bytesPrinting the uppercase version (saves 1 byte).
previous solution with help from muddyfish
fonte
Perl, 77 bytes
Requires
-E
at no extra cost.Pretty standard approach... I don't like the calls to reverse I think there's likely a more maths based approach to this, will see how I get on!
Usage
fonte
reverse
inreverse 1..25
. Thefor
needs it though.reverse1..25
results in0..25
. I'm running5.18.2
...reverse1
is undefined. Makes sense.JavaScript (ES6),
9796 bytesSaved 1 byte thanks to @user81655
Two recursive functions;
C
is the one that outputs the correct text. Try it here:Show code snippet
fonte
Python 3, 119 bytes
I tried to exploit the two symmetry axes of the diamond, but this ended up more verbose than Karl Napf's solution.
fonte
for k in range(1,27):D+=A[k:]+A[:k];D+=D[-2:-27:-1]+'\n'
'bcdefghijklmnopqrstuvwxyza'
and replacerange(1,27)
withrange(26)
. My byte count is now 114Haskell,
6766 bytesfonte
C, 252 bytes
Formatted, macro-expanded version, which is hopefully more intelligible:
I know this can't win, but I had fun trying. This is my first ever attempt at code golf.
fonte
Batch, 255 bytes
Explanation: The subroutine
u
rotates the alphabet outwards by one letter from the centre, which is the pattern used in the top half of the desired output. The subroutinel
rotates the alphabet inwards by two letters. It then falls through into theu
subroutine, achieving an effective single letter inward rotation. Finally the last line is printed by allowing the code to fall through into thel
subroutine.fonte
Pyke,
232221 bytesTry it here!
fonte
C++,
191179166165 bytes-12 bytes thanks to Kevin Cruijssen
-14 bytes thanks to Zacharý
fonte
#include<iostream> int main(){for(int i=0,j,d=1;i<53;d+=i++/26?-1:1){for(j=0;j<26;)std::cout<<char((j+++d)%26+97);for(j=24;j>=0;)std::cout<<char((j--+d)%26+97);std::cout<<'\n';};}
#define C j;)std::cout<<char(97+(d+j
, and then changing the last line to this:int main(){for(int i=0,j,d=1;i<53;d+=i++/26?-1:1){for(j=0;26>C++)%26);for(j=24;0<=C--)%26);std::cout<<'\n';};}
Charcoal,
2421 bytes-3 bytes thanks to ASCII-only.
Try it online! Link is to verbose version.
...I need to work on my Charcoal-fu. :P
fonte
Slice
is optional. >_>Slice
even do?JavaScript (ES6),
128115114 bytesfonte
Groovy -
10397 bytesI realise there are cleverer ways of doing this but...
When run the result of the script is the requested answer.
(Thanks to carusocomputing for the tip on saving 7 bytes).
Updated example accordingly on:
See http://ideone.com/MkQeoW
fonte
27.times(){}
and save 7 bytes ;).Racket 293 bytes
Ungolfed:
Testing:
Output:
fonte
Pyth,
2119 bytesTry it online!
Explanation:
fonte
SOGL V0.12, 10 bytes
Try it Here!
Explanation:
fonte
Java 8,
154153 bytesPort of @HatsuPointerKun C++ answer, so make sure to upvote him/her as well.
Try it here.
fonte
Kotlin, 106 bytes
Beautified
Test
TryItOnline
Port of @Karl Napf's answer
fonte
VBA (Excel) , 116 Bytes
Following Sir Joffan's Logic. :D
fonte
VBA,
10910578 BytesAnonymous VBE immediate window function that takes no input and outputs the alphabet diamond to the VBE immediate window.
fonte
uBASIC, 86 bytes
Try it online!
fonte
MY-BASIC, 89 bytes
Anonymous function that takes no input and outputs to the console.
Try it online!
fonte