Alphabet Diamond

33

1

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.

Magic Octopus Urn

Posted 2016-10-25T20:27:57.433

Reputation: 19 422

11Nice challenge. I personally think it would make more sense if the corners were a and the center was z – ETHproductions – 2016-10-25T20:30:16.437

6@ETHproductions I wanted to make it harder for the golfing languages who can push the alphabet ;). Though I doubt it's much harder. – Magic Octopus Urn – 2016-10-25T20:32:46.270

@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. – Erik the Outgolfer – 2016-10-26T17:01:55.133

@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. – Magic Octopus Urn – 2016-10-26T17:05:57.243

@carusocomputing I meant about b being the initial letter instead of a. Of course shifting is vital too. – Erik the Outgolfer – 2016-10-26T17:08:18.297

@carusocomputing huh? – OldBunny2800 – 2016-10-31T01:26:15.583

Answers

17

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

Emigna

Posted 2016-10-25T20:27:57.433

Reputation: 50 798

Could probably save a byte using registers and the g to calc the length of the alphabet instead of duping it. – Magic Octopus Urn – 2016-10-25T23:43:00.623

@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. – Emigna – 2016-10-26T06:20:17.523

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. – Magic Octopus Urn – 2016-10-26T14:49:06.690

@carusocomputing: Yeah, with ƒ instead of F that would indeed be 12. Nice! – Emigna – 2016-10-26T14:55:12.747

1Now you're tied with me. :3 – Oliver Ni – 2016-10-26T19:28:07.080

1@Oliver: Indeed! And with 2 different approaches in the same language :) – Emigna – 2016-10-26T19:35:27.640

27

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.

James

Posted 2016-10-25T20:27:57.433

Reputation: 54 537

I tried this program and got this.

– LegionMammal978 – 2017-06-15T13:03:22.993

Pls rerecord ty – ASCII-only – 2017-09-07T12:18:07.487

8

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

Luis Mendo

Posted 2016-10-25T20:27:57.433

Reputation: 87 464

6

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);

Jörg Hülsermann

Posted 2016-10-25T20:27:57.433

Reputation: 13 026

syntax error, unexpected '(' on line 1 Which php version? – Tschallacka – 2016-10-26T09:19:10.050

1@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 – Jörg Hülsermann – 2016-10-26T09:44:14.023

5

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

nimi

Posted 2016-10-25T20:27:57.433

Reputation: 34 639

5

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.

Level River St

Posted 2016-10-25T20:27:57.433

Reputation: 22 049

Your offset of +25 is the same as -1 in modulo 26 – Karl Napf – 2016-10-25T22:42:30.363

2@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. – Level River St – 2016-10-25T22:55:04.960

5

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.

JDL

Posted 2016-10-25T20:27:57.433

Reputation: 1 135

1Nice one! Somehow I had forgotten about the fill option for cat. Great way of printing formatted matrices. – Billywob – 2016-10-26T08:35:36.337

4

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

clap

Posted 2016-10-25T20:27:57.433

Reputation: 834

4

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

miles

Posted 2016-10-25T20:27:57.433

Reputation: 15 654

Øaṙ'JŒBŒḄY for 10 :) – Jonathan Allan – 2016-10-25T22:36:44.067

@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 – miles – 2016-10-25T23:04:19.230

Totally missed that the diamond was not perfect! Oh well... – Jonathan Allan – 2016-10-25T23:09:15.450

3

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())

ETHproductions

Posted 2016-10-25T20:27:57.433

Reputation: 47 880

@user81655 I always forget about string interpolation when newlines are involved :P – ETHproductions – 2016-10-26T13:13:42.840

3

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]

Karl Napf

Posted 2016-10-25T20:27:57.433

Reputation: 4 131

3isn't just typing the alphabet fewer chars? – Blue – 2016-10-25T20:56:56.033

3

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.

Neil

Posted 2016-10-25T20:27:57.433

Reputation: 95 035

3

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'

Dom Hastings

Posted 2016-10-25T20:27:57.433

Reputation: 16 415

You can save 1 byte by removing the whitespace after reverse in reverse 1..25. The for needs it though. – simbabque – 2016-10-26T14:31:28.117

1@simbabque maybe it's a Perl version thing, but reverse1..25 results in 0..25. I'm running 5.18.2... – Dom Hastings – 2016-10-26T15:24:14.333

You're right. Because the bareword reverse1 is undefined. Makes sense. – simbabque – 2016-10-26T15:39:04.027

3

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])

ojdo

Posted 2016-10-25T20:27:57.433

Reputation: 410

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' – FlipTack – 2016-10-30T10:55:30.113

shortened again: replace A with 'bcdefghijklmnopqrstuvwxyza' and replace range(1,27) with range(26). My byte count is now 114

– FlipTack – 2016-10-30T11:33:53.580

3

Haskell, 67 66 bytes

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

Damien

Posted 2016-10-25T20:27:57.433

Reputation: 2 407

3

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.

qzlpnfv

Posted 2016-10-25T20:27:57.433

Reputation: 31

Welcome to code golf, it's addicting haha ;). – Magic Octopus Urn – 2016-10-27T13:28:52.233

2

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

totallyhuman

Posted 2016-10-25T20:27:57.433

Reputation: 15 378

some easy bytes off – ASCII-only – 2017-09-07T08:34:40.387

Now I find out that the fourth argument to Slice is optional. >_> – totallyhuman – 2017-09-07T10:47:07.877

All (yes, all four) arguments are optional – ASCII-only – 2017-09-07T10:49:19.123

wat, what does niladic Slice even do? – totallyhuman – 2017-09-07T10:50:04.690

Same as in Python, deep copy – ASCII-only – 2017-09-07T10:50:32.680

Deep copy of what? With no arguments... – totallyhuman – 2017-09-07T10:51:21.893

2Oh wait nvm yeah the first argument is required :P – ASCII-only – 2017-09-07T10:52:02.250

oh more bytes off wait even more – ASCII-only – 2017-09-07T12:04:13.783

2

C++, 191 179 166 165 bytes

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

#include<iostream>
#define C j;)std::cout<<char(97+(d+j
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';}}

HatsuPointerKun

Posted 2016-10-25T20:27:57.433

Reputation: 1 891

1You 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';};} – Kevin Cruijssen – 2017-09-04T11:08:12.390

Dang it Kevin, ya ninja'd me. – Zacharý – 2017-09-04T13:57:04.093

@KevinCruijssen Thanks you for the help. By the way, your code in the comment contained unprintable unicode characters. – HatsuPointerKun – 2017-09-04T14:35:07.057

@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.. :) – Kevin Cruijssen – 2017-09-04T14:57:05.143

@KevinCruijssen Yup, i get "0 is an unknown identifier" and "std doesn't have cout identifier/type" and so on... – HatsuPointerKun – 2017-09-04T14:58:55.020

2You 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';};} – Zacharý – 2017-09-04T15:28:56.337

Wait ... what is that stray semicolon doing after the for loop? – Zacharý – 2017-09-04T16:08:44.553

142 bytes – ceilingcat – 2020-02-25T02:42:04.387

2

PowerShell, 64 bytes

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

Try it online!

mazzy

Posted 2016-10-25T20:27:57.433

Reputation: 4 832

2

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]

Blue

Posted 2016-10-25T20:27:57.433

Reputation: 26 661

1

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

chromaticiT

Posted 2016-10-25T20:27:57.433

Reputation: 211

1

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

dzaima

Posted 2016-10-25T20:27:57.433

Reputation: 19 048

1

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

Taylor Scott

Posted 2016-10-25T20:27:57.433

Reputation: 6 709

1

Java 10, 154 153 151 148 147 bytes

v->{var r="";for(int i=0,j=0,d=1;i<53;d+=i++>25?-1:1){for(;j<26;)r+=(char)((j+++d)%26+97);for(j--;j>0;)r+=(char)((--j+d)%26+97);r+="\n";}return r;}

Port of @HatsuPointerKun C++ answer, so make sure to upvote him/her as well.
-2 bytes thanks to @ceilingcat.
-1 byte thanks to @Grimmy.

Try it here.

Kevin Cruijssen

Posted 2016-10-25T20:27:57.433

Reputation: 67 575

-1 – Grimmy – 2020-02-25T14:48:38.710

1

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

jrtapsell

Posted 2016-10-25T20:27:57.433

Reputation: 915

1

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

remoel

Posted 2016-10-25T20:27:57.433

Reputation: 511

1

uBASIC, 86 bytes

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

Try it online!

Taylor Scott

Posted 2016-10-25T20:27:57.433

Reputation: 6 709

1

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!

Taylor Scott

Posted 2016-10-25T20:27:57.433

Reputation: 6 709

1

Visual Basic .NET (Mono), 160 bytes

Declared Subroutine that takes no input and outputs to the console.

Module M
Sub Main
Dim S,I,J
For I=-26To 26
S=""
For J=-25To 25
S+=Chr(65+(52-(Math.Abs(j)+Math.Abs(i)))Mod 26)
Next
Console.WriteLine(S)
Next
End Sub
End Module

Try it online!

Taylor Scott

Posted 2016-10-25T20:27:57.433

Reputation: 6 709

1Are you attempting to tell me that this challenge is "Basic" or something? – Magic Octopus Urn – 2018-01-31T13:23:58.207

1BA DUM TSSSSSSSSSSS – Magic Octopus Urn – 2018-01-31T13:24:24.043

@MagicOctopusUrn Lol!, Nope - I just realized that there were a couple of flavors of BASIC on TIO and thought I would give them a try - and as it turns out there are some pretty huge bugs in uBASIC (it cannot take any input on TIO at the moment) so alphabet challenges are the best I can do for all of the BASIC flavors – Taylor Scott – 2018-01-31T17:54:59.883

1

Yabasic, 74 bytes

Now I'm telling you that this challenge BASIC. /sarcasm

For i=-26To 26
For j=-25To 25
?Chr$(65+Mod(Abs(j)+Abs(i),26));
Next
?
Next

Try it online!

Taylor Scott

Posted 2016-10-25T20:27:57.433

Reputation: 6 709

1"YA BASIC!" - Had me laughing, thanks for that one lol. – Magic Octopus Urn – 2018-01-31T18:24:15.557

1

PowerShell v6+, 59 bytes

1..27+26..1|%{-join(('a'..'z'*3)[$_..($_+25)+($_+24)..$_])}

Try it online!

Ranges on ranges on ranges.

Veskah

Posted 2016-10-25T20:27:57.433

Reputation: 3 580

maybe an gu could try? – mazzy – 2020-02-25T15:27:48.683

1@mazzy I have no idea how I'd work gu into this one. If you have it, you should post it as your own. – Veskah – 2020-02-25T15:33:11.880

1

You're right. gu useless. Try it online!

– mazzy – 2020-02-25T20:54:23.507

1

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

darrylyeo

Posted 2016-10-25T20:27:57.433

Reputation: 6 214

1

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

GolfIsAGoodWalkSpoilt

Posted 2016-10-25T20:27:57.433

Reputation: 101

Instead of the for loop you can use 27.times(){} and save 7 bytes ;). – Magic Octopus Urn – 2016-10-28T13:39:07.970

1

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")

rnso

Posted 2016-10-25T20:27:57.433

Reputation: 1 635

0

J, 48 bytes

(}:@|.,])(],.}.@|."1)(1+i._26)|."0 1 a.{~97+i.26

Try it online!

Jonah

Posted 2016-10-25T20:27:57.433

Reputation: 8 729

0

Common Lisp, 221 bytes

(let((k 26)a(s"~26{~a~}~25{~a~}~%"))(#4=dotimes(i k)(push(code-char(- 90 i))a))(let*((u(append a a a))(b(reverse u)))(#4#(i 27)(#3=format t s #1=(nthcdr(1+ i)u)#2=(nthcdr(- k i)b)))(rotatef u b)(#4#(i k)(#3#t s #2##1#))))

Try it online!

More readable version:

(let (a)                             ; variable to hold the alphabet
  (dotimes (i 26)                    ; creation of the alphabet as list
    (push (code-char (- 90 i)) a))
  (let* ((u (append a a a))          ; make three copies of a
         (b (reverse u)))                ; reverse u
    (dotimes (i 27)                  ; first half: form a line with two parts
       (format t "~26{~a~}~25{~a~}~%" (nthcdr (1+ i) u) (nthcdr (- 26 i) b)))
    (rotatef u b)                    ; exchange the role of u and b
    (dotimes (i 26)                  ; second half: exchange the two parts
       (format t "~26{~a~}~25{~a~}~%" (nthcdr (- 26 i) b) (nthcdr (1+ i) u)))))

Renzo

Posted 2016-10-25T20:27:57.433

Reputation: 2 260

0

Japt, 15 bytes

;26ÆCéT±É ê
ê ·

Try it

Shaggy

Posted 2016-10-25T20:27:57.433

Reputation: 24 623

0

Dyalog APL, 31 bytes

{⍵⍪1 0↓⊖⍵}{⍵,0 1↓⌽⍵}↑(⌽∘⎕A)¨⍳27

Try it online!

Zacharý

Posted 2016-10-25T20:27:57.433

Reputation: 5 710

0

q/kdb+, 51 bytes

Solution:

-1 .Q.a t{rotate[y;x]x,1_(|)x}/:(1+t),1,(-)t:(!)26;

Explanation:

Build the range of 1..26,1,0,-1..-25, feed this into a lambda that rotates the range 0..25 and indexes in at the range 0..25,24..0... Then use this to index into the lowercase alphabet.

-1 .Q.a t{rotate[y;x]x,1_reverse x}/:(1+t),1,neg t:til 26; / ungolfed
-1                                                       ; / print to stdout and swallow return value
                                                 t:til 26  / store range of 0..25 in variable t
                                             neg           / negate (0..-25)
                                           1,              / prepend 1
                                     (1+t),                / prepend 1+t (1..26)
        t{                        }/:                      / lambda function with parameters t, and each-right
                         reverse x                         / x = t = 0..25, reversed is 25..0
                       1_                                  / 1 drop, so 24..0
                     x,                                    / prepend x, so 0..25,24..0
          rotate[y;x]                                      / rotate x by y (rotate[1;"abc"] -> "bca")
   .Q.a                                                    / index into alphabet at these indices

Notes:

Feels like it should be able to be golfed further, building the ranges seems clunky.

streetster

Posted 2016-10-25T20:27:57.433

Reputation: 3 635

0

Recursiva, 44 25 21 19 bytes

{p+)'a'"Pp+J''_Q)}}

Try it online!

Explanation:

{p+)'a'"Pp+J''_Q)}}
{                     - For each
 p+)'a'               - 'abc..xyzazyx..abc'
       "              - Iteration command begin
        P             - Print
         p            - palindromize 'cde..xyzabazyx..cde'
          +           - concatenate 'cde..xyzab'
           J''        - join with nothing 'cde..xyza'
              _       - reverse ['cde...xyz', 'a']
               Q)}    - split ) at } ['a','cdef..xyz']
                  }   - current element (say 'b' for 2nd iteration)

officialaimm

Posted 2016-10-25T20:27:57.433

Reputation: 2 739

0

Retina, 166 bytes


bcdefghijklmnopqrstuvwxyzazyxwvutsrqponmlkjihgfedcb____________________________________________________
+(`([a-z]+)_(_+)
$1¶$1$2¶$1
(.)(.{24})(.)(.{24})._
$2$3$1$3$4

Try it online!

Dom Hastings

Posted 2016-10-25T20:27:57.433

Reputation: 16 415

0

APL (Dyalog Classic), 21 bytes

(⍉⊢⍪1↓⊖)⍣2⍉1↓27 27⍴⎕a

Try it online!

With the alphabet (⎕a) fill in row-major order a 27x27 matrix (27 27⍴), then drop the first row (1↓) and transpose ().

Do this twice (⍣2): concatenate to the bottom () of this matrix () a vertically reversed copy () without its first row (1↓) and transpose () the result.

ngn

Posted 2016-10-25T20:27:57.433

Reputation: 11 449

0

05AB1E, 9 bytes

Aā._Ć€ûû»

Try it online!

Grimmy

Posted 2016-10-25T20:27:57.433

Reputation: 12 521