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

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\$
3
  • 1
    \$\begingroup\$ Are you attempting to tell me that this challenge is "Basic" or something? \$\endgroup\$ Jan 31, 2018 at 13:23
  • 1
    \$\begingroup\$ BA DUM TSSSSSSSSSSS \$\endgroup\$ Jan 31, 2018 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\$ Jan 31, 2018 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
  • 1
    \$\begingroup\$ "YA BASIC!" - Had me laughing, thanks for that one lol. \$\endgroup\$ Jan 31, 2018 at 18:24
1
\$\begingroup\$

05AB1E, 9 bytes

Aā._Ć€ûû»

Try it online!

\$\endgroup\$
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\$
3
  • \$\begingroup\$ maybe an gu could try? \$\endgroup\$
    – mazzy
    Feb 25, 2020 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, 2020 at 15:33
  • 1
    \$\begingroup\$ You're right. gu useless. Try it online! \$\endgroup\$
    – mazzy
    Feb 25, 2020 at 20:54
1
\$\begingroup\$

Java 10, 154 153 151 148 147 142 141 bytes

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

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

Try it here.

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

FALSE, 137 bytes

1c:53 0$d:[65@$0=~\1-\][@@\c;+d;1=[1_c:]?$26=[%0 1d:]?$1_=[%25]?$@+1b:51[$0=~][$26=[1_b:]?\$,b;+[$a:$64=[90a:]?91=[65a:]?a;]!\1-]#%%10,]#

Try it online!

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

Vyxal jr, 11 bytes

27ƛkaǓøm;øm

Try it Online!

Explanation:

27ƛ     ;    # For each number x in range [1..27]:
   ka        #   Lowercase alphabet
     Ǔ       #   Rotate it left x times
      øm     #   Mirror without duplicating middle
         øm  # Mirror without duplicating middle
             # 'j' flag - Join top of stack with newlines and print
\$\endgroup\$
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\$

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\$

Stax, 13 bytes

éÑ8╟╘"╧ö↑D☼▓}

Run and debug it

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

Elixir, 111 bytes

import Enum
c=?a..?z
a=map 1..26,&(drop(c,&1)++slice c,0,&1)
map a++[hd a]++reverse(a),&IO.puts&1++tl reverse&1

Try it online!

Feel like there are some key savings I'm missing here...

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

Japt -R, 15 12 bytes

;26ÆCé´T êÃê

Test it

;26ÆCé´T êÃê
 26Æ             :Map the range [0,26)
;   C            :  Lowercase alphabet
     é           :  Rotate right by
      ´T         :    T (initially 0) prefix decremented
         ê       :  Palindromise
          Ã      :End map
           ê     :Palindromise
                 :Implicit output joined with newlines
\$\endgroup\$
1
2

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.