35
\$\begingroup\$

You've seen the amazing alphabet triangle, the revenge of the alphabet triangle and now it's time for the revenge of the revenge of the alphabet triangle!

Introducing...

THE ALPHABET DIAMOND!

Your task is to output this exact text, lowercase/uppercase does not matter, though newlines do:

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

This is code-golf, lowest bytecount wins.

Rules:

  1. Standard loopholes are disallowed.
  2. a must be the center of the alphabet diamond.
\$\endgroup\$
6
  • 12
    \$\begingroup\$ Nice challenge. I personally think it would make more sense if the corners were a and the center was z \$\endgroup\$ Oct 25, 2016 at 20:30
  • 7
    \$\begingroup\$ @ETHproductions I wanted to make it harder for the golfing languages who can push the alphabet ;). Though I doubt it's much harder. \$\endgroup\$ Oct 25, 2016 at 20:32
  • \$\begingroup\$ @carusocomputing A left rotate would do it. For example, .< would do it in Pyth: .<S5 1 would result in [2, 3, 4, 5, 1]. It is the same as .<[1 2 3 4 5)1. Not sure for the diamond, though. \$\endgroup\$ Oct 26, 2016 at 17:01
  • \$\begingroup\$ @EriktheGolfer I realize, there are some smarter ways to do it too, like collapsing the shift in a do-while. The diamond itself should require shifting, so there are ways to combine the initial shift in the actual diamond iterations as well. It was an intentional part of the challenge to see who optimized their looping. \$\endgroup\$ Oct 26, 2016 at 17:05
  • \$\begingroup\$ @carusocomputing I meant about b being the initial letter instead of a. Of course shifting is vital too. \$\endgroup\$ Oct 26, 2016 at 17:08

47 Answers 47

29
\$\begingroup\$

Vim, 62, 60 keystrokes

:se ri|h<_<cr>jjYZZPqqx$pYpq26@qdjyH:g/^/m0<cr>VP:%norm DPA<C-v><C-r>"<C-v><esc>x<cr>

Drawing on inspiration from Lynn's awesome vim answer to take the idea of stealing the alphabet from the help docs.

You can watch it happen in real time as I struggle to remember the right sequence of keystrokes!

enter image description here

Note that this gif is slightly outdated because it produces the wrong output, and I haven't gotten around to re-recording it yet.

\$\endgroup\$
2
  • \$\begingroup\$ I tried this program and got this. \$\endgroup\$ Jun 15, 2017 at 13:03
  • \$\begingroup\$ Pls rerecord ty \$\endgroup\$
    – ASCII-only
    Sep 7, 2017 at 12:18
18
\$\begingroup\$

05AB1E, 13 12 bytes

A27FÀDûˆ}¯û»

Try it online!

Explanation

A              # push alphabet
 27F           # 27 times do
    À          # rotate alphabet left
     Dû        # create a palendromized copy
       ˆ       # add to global list
        }      # end loop
         ¯     # push global list
          û    # palendromize list
           »   # merge list on newline
               # implicit output
\$\endgroup\$
6
  • \$\begingroup\$ Could probably save a byte using registers and the g to calc the length of the alphabet instead of duping it. \$\endgroup\$ Oct 25, 2016 at 23:43
  • \$\begingroup\$ @carusocomputing: Unless I'm doing it wrong (feel free to educate me if that is the case) I ended up at 13 doing that. I did manage to save a byte with the global list though. \$\endgroup\$
    – Emigna
    Oct 26, 2016 at 6:20
  • \$\begingroup\$ A©gF®À©û})û» is what I was thinking. By no means are you ever doing it wrong! I've learned all I know from watching you heh. The global list is the same basic idea. \$\endgroup\$ Oct 26, 2016 at 14:49
  • 1
    \$\begingroup\$ Now you're tied with me. :3 \$\endgroup\$
    – Oliver Ni
    Oct 26, 2016 at 19:28
  • 1
    \$\begingroup\$ @Oliver: Indeed! And with 2 different approaches in the same language :) \$\endgroup\$
    – Emigna
    Oct 26, 2016 at 19:35
8
\$\begingroup\$

MATL, 14 bytes

2Y226Zv27Zv!+)

Try it online!

2Y2     % Push string 'abc...z'
26Zv    % Push symmetric range [1 2 ... 25 26 25 ... 2 1]
27Zv    % Push symmetric range [1 2 ... 25 26 27 26 25 ... 2 1]
!       % Transpose into a column
+       % Addition with broadcast. Gives a matrix of all pairwise additions:
        % [  2  3 ... 26 27 26 ...  3  2
             3  4 ... 27 28 27 ...  4  3
             ...
            27 28 ... 51 52 51 ... 28 27
            28 29 ... 52 53 52 ... 29 28
            27 28 ... 51 52 51 ... 28 27
             ...
             2  3 ... 26 27 26 ...  3  2 ]
)       % Index modularly into the string. Display implicitly
\$\endgroup\$
6
\$\begingroup\$

PHP, 129 Bytes

for(;++$i<27;)$o.=($s=($f=substr)($r=join(range(a,z)),$i,26-$i)).$t.strrev($s.$t=$f($r,0,$i))."\n";echo$o.$f($o,0,51).strrev($o);
\$\endgroup\$
2
  • \$\begingroup\$ syntax error, unexpected '(' on line 1 Which php version? \$\endgroup\$ Oct 26, 2016 at 9:19
  • 1
    \$\begingroup\$ @Tschallacka PHP > 7 before you can write 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 error \$\endgroup\$ Oct 26, 2016 at 9:44
5
\$\begingroup\$

Haskell, 75 bytes

g=(++)<*>reverse.init 
unlines$g$g.take 26.($cycle['a'..'z']).drop<$>[1..27]

How it works:

g=(++)<*>reverse.init    -- helper function that takes a list and appends the
                         -- reverse of the list with the first element dropped, e.g.
                         -- g "abc"  -> "abcba"

             <$>[1..27]  -- map over the list [1..27] the function that
           drop          -- drops that many elements from
    ($cycle['a'..'z'])   -- the infinite cycled alphabet and
   take 26               -- keeps the next 26 chars and
  g                      -- appends the reverse of itself

                         -- now we have the first 27 lines

 g                       -- do another g to append the lower half
unlines                  -- join with newlines
\$\endgroup\$
5
\$\begingroup\$

Jelly, 13 bytes

Øaṙ1ṭṙJ$ŒBŒḄY

Try it online!

Explanation

Øaṙ1ṭṙJ$ŒBŒḄY  Main link. No arguments
Øa             Get the lowercase alphabet
  ṙ1           Rotate left by 1
    ṭ          Append to
       $       Monadic chain
      J          Indices of the alphabet [1, 2, ..., 26]
     ṙ           Rotate the alphabet by each
        ŒB     Bounce each rotation
          ŒḄ   Bounce the rotations
            Y  Join with newlines and print implicitly
\$\endgroup\$
3
  • \$\begingroup\$ Øaṙ'JŒBŒḄY for 10 :) \$\endgroup\$ Oct 25, 2016 at 22:36
  • \$\begingroup\$ @JonathanAllan Thanks but that's missing the middle part which is why I had to do that ṙ1ṭ bit. Also ØaṙJŒBŒḄY is fine, you don't need the quick since it vectorizes on the right to 0 \$\endgroup\$
    – miles
    Oct 25, 2016 at 23:04
  • \$\begingroup\$ Totally missed that the diamond was not perfect! Oh well... \$\endgroup\$ Oct 25, 2016 at 23:09
5
\$\begingroup\$

C, 76 bytes

Function, to be called as below. Prints capital letters.

f(i){for(i=2756;--i;)putchar(i%52?90-(abs(i%52-26)+abs(i/52-26)+25)%26:10);}

//call like this
main(){f();}

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 from 90, the ASCII code for Z. Where i%52==0 a newline ASCII 10 is printed.

\$\endgroup\$
2
  • \$\begingroup\$ Your offset of +25 is the same as -1 in modulo 26 \$\endgroup\$
    – Karl Napf
    Oct 25, 2016 at 22:42
  • 2
    \$\begingroup\$ @KarlNapf C doesn't implement modulo of negative numbers the way mathematicians do. -1%26 in C is -1, not 25. The result is a [ in the centre instead of the expected A. Thanks anyway, you would have been correct in a language such as Ruby where -1%26 does equal 25. \$\endgroup\$ Oct 25, 2016 at 22:55
5
\$\begingroup\$

R, 71 bytes

cat(letters[outer(c(1:27,26:1),c(0:25,24:0),"+")%%26+1],sep="",fill=53)

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice one! Somehow I had forgotten about the fill option for cat. Great way of printing formatted matrices. \$\endgroup\$
    – Billywob
    Oct 26, 2016 at 8:35
5
\$\begingroup\$

Jelly, 11 bytes

27RØaṙŒḄŒBY

Explanation:

27R          range of 1...27
   Øa        the alphabet
     ṙ       rotate
      ŒḄŒB   bounce in both dimensions
          Y  join on newline
\$\endgroup\$
3
\$\begingroup\$

Python 2, 96 85 bytes

Printing the uppercase version (saves 1 byte).

R=range
for i in R(53):print''.join(chr(90-(abs(j-25)+abs(i-26)-1)%26)for j in R(51))

previous solution with help from muddyfish

s="abcdefghijklmnopqrstuvwxyz"*3
for i in range(53):j=min(i,52-i);print s[j+1:j+27]+s[j+25:j:-1]
\$\endgroup\$
1
  • 3
    \$\begingroup\$ isn't just typing the alphabet fewer chars? \$\endgroup\$
    – Blue
    Oct 25, 2016 at 20:56
3
\$\begingroup\$

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!

@a=((a..z)x3)[$_..$_+26],$a=pop@a,(say@a,$a,reverse@a)for 1..26,reverse 1..25

Usage

perl -E '@a=((a..z)x3)[$_..$_+26],$a=pop@a,(say@a,$a,reverse@a)for 1..26,reverse 1..25'
\$\endgroup\$
3
  • \$\begingroup\$ You can save 1 byte by removing the whitespace after reverse in reverse 1..25. The for needs it though. \$\endgroup\$
    – simbabque
    Oct 26, 2016 at 14:31
  • 1
    \$\begingroup\$ @simbabque maybe it's a Perl version thing, but reverse1..25 results in 0..25. I'm running 5.18.2... \$\endgroup\$ Oct 26, 2016 at 15:24
  • \$\begingroup\$ You're right. Because the bareword reverse1 is undefined. Makes sense. \$\endgroup\$
    – simbabque
    Oct 26, 2016 at 15:39
3
\$\begingroup\$

JavaScript (ES6), 97 96 bytes

Saved 1 byte thanks to @user81655

R=(n,s=25,c=(n%26+10).toString(36))=>s?c+R(n+1,s-1)+c:c
C=(n=1,r=R(n))=>n<27?r+`
${C(n+1)}
`+r:r

Two recursive functions; C is the one that outputs the correct text. Try it here:

R=(n,s=25,c=(n%26+10).toString(36))=>s?c+R(n+1,s-1)+c:c
C=(n=1,r=R(n))=>n<27?r+`
${C(n+1)}
`+r:r

console.log(C())

\$\endgroup\$
1
  • \$\begingroup\$ @user81655 I always forget about string interpolation when newlines are involved :P \$\endgroup\$ Oct 26, 2016 at 13:13
3
\$\begingroup\$

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.

A='abcdefghijklmnopqrstuvwxyz'
D=''
for k in range(1,27):
 D+=A[k:]+A[:k]
 D+=D[-2:-27:-1]+'\n'
print(D+D[:51]+D[::-1])
\$\endgroup\$
2
  • \$\begingroup\$ A good solution nonetheless! You can cut down 3 bytes by writing the for loop in 1 line: for k in range(1,27):D+=A[k:]+A[:k];D+=D[-2:-27:-1]+'\n' \$\endgroup\$
    – FlipTack
    Oct 30, 2016 at 10:55
  • \$\begingroup\$ shortened again: replace A with 'bcdefghijklmnopqrstuvwxyza' and replace range(1,27) with range(26). My byte count is now 114 \$\endgroup\$
    – FlipTack
    Oct 30, 2016 at 11:33
3
\$\begingroup\$

Haskell, 67 66 bytes

unlines[[toEnum$mod(-abs j-abs i)26+97|j<-[-25..25]]|i<-[-26..26]]
\$\endgroup\$
3
\$\begingroup\$

C, 252 bytes

#define j q[y]
#define k(w,v) (v<'z')?(w=v+1):(w=97)
char q[28][52],d;main(){int y,x=1;y=1;j[0]=98;j[50]=98;for(;y<27;y++){for(;x<26;x++){(x<1)?(k(d,q[y-1][50])):(k(d,j[x-1]));j[50-x]=d;j[x]=d;}x=0;j[51]=0;puts(j);}strcpy(j,q[1]);for(;y;y--)puts(j);}

Formatted, macro-expanded version, which is hopefully more intelligible:

#define j q[y]
#define k(w,v) (v<'z')?(w=v+1):(w=97)
char q[28][52],d;
main(){
int y,x=1;
y=1;
q[1][0]=98;q[1][50]=98;
//98 takes one less byte to type than the equivalent 'b'
for(;y<27;y++){
    for(;x<26;x++){
        (x<1)?
            (k(d,q[y-1][50]))
            :(k(d,q[y][x-1]));
        q[y][50-x]=d;
        q[y][x]=d;
        }
    x=0;
    q[y][51]=0;
    puts(q[y]);
    }
strcpy(q[y],q[1]);
for(;y;y--)puts(q[y]);
}

I know this can't win, but I had fun trying. This is my first ever attempt at code golf.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to code golf, it's addicting haha ;). \$\endgroup\$ Oct 27, 2016 at 13:28
3
\$\begingroup\$

Batch, 255 bytes

@echo off
set l=abcdefghijklmnopqrstuvwxyz
set r=yxwvutsrqponmlkjihgfedcba
for /l %%i in (1,1,27)do call:u
for /l %%i in (1,1,25)do call:l
:l
set r=%r:~2%%l:~-1%.
set l=%l:~-2%%l:~0,-2%
:u
set r=%l:~-1%%r:~0,-1%
set l=%l:~1%%l:~0,1%
echo %l%%r%

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 subroutine l rotates the alphabet inwards by two letters. It then falls through into the u subroutine, achieving an effective single letter inward rotation. Finally the last line is printed by allowing the code to fall through into the l subroutine.

\$\endgroup\$
2
\$\begingroup\$

Pyke, 23 22 21 bytes

GV'th+jj_t+j)K]0n'JOX

Try it here!

GV          )         - repeat 26 times, initially push alphabet.
  'th+                -  push tos[1:]+tos[0]
      j               -  j = tos
       j              -  push j
        _t+           -  push pop+reversed(pop)[1:]
           j          -  push j
             K        - pop
              ]0      - list(stack)
                n'JOX - print "\n".join(^),
                      - splat ^[:-1]
\$\endgroup\$
2
\$\begingroup\$

Charcoal, 24 21 bytes

-3 bytes thanks to ASCII-only.

F²⁷«P✂×β³⊕ι⁺ι²⁷↓»‖B↓→

Try it online! Link is to verbose version.

...I need to work on my Charcoal-fu. :P

\$\endgroup\$
8
  • \$\begingroup\$ some easy bytes off \$\endgroup\$
    – ASCII-only
    Sep 7, 2017 at 8:34
  • \$\begingroup\$ Now I find out that the fourth argument to Slice is optional. >_> \$\endgroup\$ Sep 7, 2017 at 10:47
  • \$\begingroup\$ All (yes, all four) arguments are optional \$\endgroup\$
    – ASCII-only
    Sep 7, 2017 at 10:49
  • \$\begingroup\$ wat, what does niladic Slice even do? \$\endgroup\$ Sep 7, 2017 at 10:50
  • 2
    \$\begingroup\$ Oh wait nvm yeah the first argument is required :P \$\endgroup\$
    – ASCII-only
    Sep 7, 2017 at 10:52
2
\$\begingroup\$

VBA (Excel) , 116 Bytes

Sub a()
For i=-26To 26
For j=-25To 25
b=b & Chr(65+(52-(Abs(j)+Abs(i))) Mod 26)
Next
Debug.Print b
b=""
Next
End Sub

Following Sir Joffan's Logic. :D

\$\endgroup\$
2
\$\begingroup\$

VBA, 109 105 78 Bytes

Anonymous VBE immediate window function that takes no input and outputs the alphabet diamond to the VBE immediate window.

For i=-26To 26:For j=-25To 25:?Chr(65+(52-(Abs(j)+Abs(i)))Mod 26);:Next:?:Next
\$\endgroup\$
2
\$\begingroup\$

PowerShell, 64 bytes

1..27+26..1|%{$y=$_
-join(0..25+24..0|%{[char](97+($_+$y)%26)})}

Try it online!

\$\endgroup\$
2
\$\begingroup\$

C++, 191 179 166 165 139 bytes

-12 bytes thanks to Kevin Cruijssen
-14 bytes thanks to Zacharý -26 bytes thanks to ceilingcat

#import<cstdio>
#define C j;)putchar(97+j
main(){for(int i=0,j,d=1;i<53;d+=i++/26?-1:1){for(j=d;26+d>C++%26);for(j--;d<=--C%26);puts("");}}
\$\endgroup\$
8
  • 1
    \$\begingroup\$ You can save 12 bytes like this: #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';};} \$\endgroup\$ Sep 4, 2017 at 11:08
  • \$\begingroup\$ Dang it Kevin, ya ninja'd me. \$\endgroup\$
    – Adalynn
    Sep 4, 2017 at 13:57
  • \$\begingroup\$ @KevinCruijssen Thanks you for the help. By the way, your code in the comment contained unprintable unicode characters. \$\endgroup\$ Sep 4, 2017 at 14:35
  • \$\begingroup\$ @HatsuPointerKun That's something that happens automatically in the comments I'm afraid. It's indeed pretty annoying when you try to copy-paste code from it.. :) \$\endgroup\$ Sep 4, 2017 at 14:57
  • 2
    \$\begingroup\$ You can abuse macros by adding this: #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';};} \$\endgroup\$
    – Adalynn
    Sep 4, 2017 at 15:28
1
\$\begingroup\$

JavaScript (ES6), 128 115 114 bytes

a='abcdefghijklmnopqrstuvwxyz'
for(o=[i=27];i--;)o[26-i]=o[26+i]=(a=(p=a.slice(1))+a[0])+[...p].reverse().join``
o
\$\endgroup\$
1
\$\begingroup\$

Groovy - 103 97 bytes

I realise there are cleverer ways of doing this but...

{t=('a'..'z').join();q={it[-2..0]};c=[];27.times{t=t[1..-1]+t[0];c<<t+q(t)};(c+q(c)).join('\n')}

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

\$\endgroup\$
1
  • \$\begingroup\$ Instead of the for loop you can use 27.times(){} and save 7 bytes ;). \$\endgroup\$ Oct 28, 2016 at 13:39
1
\$\begingroup\$

Racket 293 bytes

(let*((ls list->string)(rr reverse)(sr(λ(s)(ls(rr(string->list s))))))(let p((s(ls(for/list((i(range 97 123)))(integer->char i))))
(n 0)(ol'()))(let*((c(string-ref s 0))(ss(substring s 1 26))(s(string-append ss(string c)(sr ss))))(if(< n 53)(p s(+ 1 n)(cons s ol))
(append(rr ol)(cdr ol))))))

Ungolfed:

(define (f)
  (define (sr s)           ; sub-fn reverse string;
    (list->string
     (reverse
      (string->list s))))
  (let loop ((s
              (list->string
               (for/list
                   ((i
                     (range 97 123)))
                 (integer->char i))))
             (n 0)
             (ol '()))
    (define c (string-ref s 0))
    (define ss (substring s 1 26))
    (set! s (string-append
             ss 
             (string c)
             (sr ss)))
    (if (< n 53)
        (loop s (add1 n) (cons s ol))
        (append (reverse ol) (rest ol)))))

Testing:

(f)

Output:

'("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"
  "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"
  "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")
\$\endgroup\$
1
\$\begingroup\$

Pyth, 21 19 bytes

j+PKm+PJ.<Gd_JS27_K

Try it online!

Explanation:

j+PKm+PJ.<Gd_JS27_K   expects no input

j                     joins on new line
 +   +                joins two strings
  P   P               prints everything but the last element
   K                  initialize K and implicitly print
    m                 for...in loop, uses d as iterator variable
       J              initialize J and implicitly print
        .<            cyclically rotate
          G           initialized to the lowercase alphabet
           d          iterating variables of m
            _    _    reverse
             J        call J
              S27     indexed range of 27
                  K   call K
\$\endgroup\$
1
\$\begingroup\$

SOGL V0.12, 10 bytes

zl{«:}«¹╬,

Try it Here!

Explanation:

z           push the lowercase alphabet
 l{  }      repeat length times
   «          put the 1st letter at the end
    :         duplicate
      «     put the 1st letter at the end (as the last thing called is duplicate)
       ¹    wrap the stack in an array
        ╬,  quad-palindromize with 1 X and Y overlap
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 106 bytes

{(0..52).map{i->(0..50).map{j->print((90-((Math.abs(j-25)+Math.abs(i-26)-1)+26)%26).toChar())}
println()}}

Beautified

{
    (0..52).map {i->
        (0..50).map {j->
            print((90 - ((Math.abs(j - 25) + Math.abs(i - 26) - 1)+26) % 26).toChar())
        }
        println()
    }
}

Test

var v:()->Unit =
{(0..52).map{i->(0..50).map{j->print((90-((Math.abs(j-25)+Math.abs(i-26)-1)+26)%26).toChar())}
println()}}

fun main(args: Array<String>) {
    v()
}

TryItOnline

Port of @Karl Napf's answer

\$\endgroup\$
1
\$\begingroup\$

uBASIC, 86 bytes

0ForI=-26To26:ForJ=-25To25:?Left$(Chr$(65+(52-(Abs(J)+Abs(I)))Mod26),1);:NextJ:?:NextI

Try it online!

\$\endgroup\$
1
\$\begingroup\$

MY-BASIC, 89 bytes

Anonymous function that takes no input and outputs to the console.

For i=-26 To 26
For j=-25 To 25
Print Chr(65+(52-(Abs(j)+Abs(i)))Mod 26)
Next
Print;
Next

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.