33
\$\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\$
  • 11
    \$\begingroup\$ Nice challenge. I personally think it would make more sense if the corners were a and the center was z \$\endgroup\$ – ETHproductions Oct 25 '16 at 20:30
  • 6
    \$\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\$ – Magic Octopus Urn Oct 25 '16 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\$ – Erik the Outgolfer Oct 26 '16 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\$ – Magic Octopus Urn Oct 26 '16 at 17:05
  • \$\begingroup\$ @carusocomputing I meant about b being the initial letter instead of a. Of course shifting is vital too. \$\endgroup\$ – Erik the Outgolfer Oct 26 '16 at 17:08

43 Answers 43

1
2
1
\$\begingroup\$

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ Are you attempting to tell me that this challenge is "Basic" or something? \$\endgroup\$ – Magic Octopus Urn Jan 31 '18 at 13:23
  • 1
    \$\begingroup\$ BA DUM TSSSSSSSSSSS \$\endgroup\$ – Magic Octopus Urn Jan 31 '18 at 13:24
  • \$\begingroup\$ @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 \$\endgroup\$ – Taylor Scott Jan 31 '18 at 17:54
1
\$\begingroup\$

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ "YA BASIC!" - Had me laughing, thanks for that one lol. \$\endgroup\$ – Magic Octopus Urn Jan 31 '18 at 18:24
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ -1 \$\endgroup\$ – Grimmy Feb 25 at 14:48
1
\$\begingroup\$

PowerShell v6+, 59 bytes

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

Try it online!

Ranges on ranges on ranges.

\$\endgroup\$
  • \$\begingroup\$ maybe an gu could try? \$\endgroup\$ – mazzy Feb 25 at 15:27
  • 1
    \$\begingroup\$ @mazzy I have no idea how I'd work gu into this one. If you have it, you should post it as your own. \$\endgroup\$ – Veskah Feb 25 at 15:33
  • 1
    \$\begingroup\$ You're right. gu useless. Try it online! \$\endgroup\$ – mazzy Feb 25 at 20:54
0
\$\begingroup\$

J, 48 bytes

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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

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)))))
\$\endgroup\$
0
\$\begingroup\$

Japt, 15 bytes

;26ÆCéT±É ê
ê ·

Try it

\$\endgroup\$
0
\$\begingroup\$

Dyalog APL, 31 bytes

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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Retina, 166 bytes


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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

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)
\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 9 bytes

Aā._Ć€ûû»

Try it online!

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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