43
\$\begingroup\$

Description

Output the rhyme scheme for a very long Terza Rima.

Input

None.

Output

ABA
BCB
CDC
DED
EFE
FGF
GHG
HIH
IJI
JKJ
KLK
LML
MNM
NON
OPO
PQP
QRQ
RSR
STS
TUT
UVU
VWV
WXW
XYX
YZY

Rules

You can pick between separating stanzas with whitespace or newlines, so either:

ABA BCB...

OR

ABA
BCB
...

A single trailing whitespace allowed per line and one trailing newline allowed.

Output can be either uppercase or lowercase.

This is , so the shortest code in bytes for each language wins.

\$\endgroup\$
9
  • 4
    \$\begingroup\$ Is a list of lines okay? \$\endgroup\$ Dec 18, 2017 at 16:23
  • 6
    \$\begingroup\$ According to en.wikipedia.org/wiki/Terza_rima your ending is wrong. It should end with either Z or ZZ. \$\endgroup\$
    – Chris
    Dec 18, 2017 at 18:28
  • \$\begingroup\$ Can there be additional output beyond the rhyme scheme? This might save me a few bytes. \$\endgroup\$
    – NK1406
    Dec 18, 2017 at 23:02
  • \$\begingroup\$ @NK1406 Nope sorry. \$\endgroup\$
    – LiefdeWen
    Dec 19, 2017 at 7:13
  • 1
    \$\begingroup\$ @totallyhuman String array is fine. \$\endgroup\$
    – LiefdeWen
    Dec 19, 2017 at 7:14

90 Answers 90

1 2
3
1
\$\begingroup\$

K (oK), 17 16 bytes

Solution:

`c$010b+/:65+!25

Try it online!

Explanation:

Might be a better way, but this is what I came up with:

`c$010b+/:65+!25 / the solution
             !25 / til 25 => 0..24
          65+    / add 65 -> 65..89 
       +/:       / add left to each right
   010b          / boolean array of 0 1 0
`c$              / cast to ASCII characters
\$\endgroup\$
1
\$\begingroup\$

K4, 15 bytes

Solution:

+-1 1 -1_\:.Q.A

Explanation:

Take A..Z, drop the last/first/last elements and then transpose:

+-1 1 -1_\:.Q.A / the solution
           .Q.A / "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        _\:     / drop (_) each-left from the right argument
 -1 1 -1        / the list (-1;1;-1)
+               / flip
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 17 bytes

90,65>''+{.).(n}%

Try it online!

Explanation

90,65>            # Yield the uppercase alphabet
      ''+         # Convert to a string
         {     }% # For every codepoint in the string:
          .)      # Push the codepoint incremented
            .(    # Push the codepoint decremented
              n   # Push a newline
\$\endgroup\$
1
\$\begingroup\$

naz, 60 bytes

8a8m2x1v2d3m7s2x2v1x1f1v1a1o1a1o1s1o2x1v0m9a1a1o1v3x2v1l0x1f

Explanation (with 0x commands removed)

8a8m2x1v                               # Set variable 1 equal to 64 ("@")
2d3m7s2x2v                             # Set variable 2 equal to 89 ("Y")
1x1f                                   # Function 1
    1v                                 # Load variable 1 into the register
      1a1o1a1o1s1o                     # Output the next line of the rhyme scheme
                  2x1v                 # Store the value of the register in variable 1
                      0m9a1a1o         # Output a newline
                              1v       # Load variable 1 into the register
                                3x2v1l # Jump back to the start of the function
                                       # if the value in the register is less than variable 2
1f                                     # Call function 1
\$\endgroup\$
1
\$\begingroup\$

Python 3, 49 47 bytes

An obvious golf saved 2 bytes:

' '.join('%c'*3%(x,x+1,x)for x in range(65,90))

Try it online

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

Forth (gforth), 55 53 46 bytes

: f 90 65 do i i 1+ i emit emit emit cr loop ;

Try it online!

-6 bytes from bubbler.

a simple loop.

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

Deadfish~, 674 bytes

{iiiiii}iiiiicicdc{ddddd}dddddc{iiiii}iiiiiicicdc{ddddd}ddddddc{iiiiii}dddcicdc{dddddd}iiic{iiiiii}ddcicdc{dddddd}iic{iiiiii}dcicdc{dddddd}ic{iiiiii}cicdc{dddddd}c{iiiiii}icicdc{dddddd}dc{iiiiii}iicicdc{dddddd}ddc{iiiiii}iiicicdc{dddddd}dddc{iiiiii}iiiicicdc{dddddd}ddddc{iiiiii}iiiiicicdc{dddddd}dddddc{iiiiii}iiiiiicicdc{dddddd}ddddddc{{i}ddd}dddcicdc{{d}iii}iiic{{i}ddd}ddcicdc{{d}iii}iic{{i}ddd}dcicdc{{d}iii}ic{{i}ddd}cicdc{{d}iii}c{{i}ddd}icicdc{{d}iii}dc{{i}ddd}iicicdc{{d}iii}ddc{{i}ddd}iiicicdc{{d}iii}dddc{{i}ddd}iiiicicdc{{d}iii}ddddc{{i}ddd}iiiiicicdc{{d}iii}dddddc{{i}ddd}iiiiiicicdc{{d}iii}ddddddc{{i}dd}dddcicdc{{d}ii}iiic{{i}dd}ddcicdc{{d}ii}iic{{i}dd}dcicdc

Try it online!

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

Stax, 6 bytes

╢#^↔2f

Run and debug it

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

Vyxal j, 12 bytes

kA:2l$Zƛfṅ;Ṫ

Try it Online!

Nice effort by @Ausername, +1 to them. I tried a different approach:

ka          # uppercase alphabet
:           # dup
2l          # pairwise
$           # swap
Z           # zip
ƛ           # map
 f          # flatten
 ṅ          # join
;           # close map
Ṫ           # slice without tail

Although not necessary, for beautification, I added the j flag.

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

Excel, 46 bytes

Multiple lines

=CONCAT(CHAR(ROW(65:89)*{1,1,1,0}+{0,1,0,10}))

One line

=CONCAT(CHAR(ROW(65:89)*{1,1,1,0}+{0,1,0,32}))

25 by 3 array of cells, 25 bytes

=CHAR(ROW(65:89)+{0,1,0})

I don't think this follows the spirit of the challenge but it is shorter.

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

Uiua, 21 bytes

≡&p↘¯1⍉⍜⊙⊡↻.1↯3+@A⇡26

Pad

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

Uiua SBCS, 12 10 bytes

⊞+⇡25"ABA"

Try it!

-2 bytes thanks to Lynn!

\$\endgroup\$
2
  • \$\begingroup\$ ⊞+⇡25"ABA" seems to work. \$\endgroup\$
    – lynn
    Mar 24 at 0:16
  • \$\begingroup\$ @Lynn Nice, thanks. \$\endgroup\$
    – chunes
    Mar 24 at 0:43
1
\$\begingroup\$

Pip -l, 7 bytes

BWR_MPz

Attempt This Online!

Explanation

BWR_MPz
      z ; Lowercase alphabet
    MP  ; Map this function to each adjacent pair of letters:
B       ;   The second letter
 WR     ;   Wrapped in two copies of
   _    ;   The first letter
        ; Autoprint the resulting list one element per line (-l flag)
\$\endgroup\$
0
\$\begingroup\$

SOGL V0.12, 7 bytes

ZZ«Z⁰Ij

Try it Here!

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

Standard ML (MLton), 62 bytes

fun$90=""| $n=implode(map chr[n,n+1,n,32])^ $(n+1);print($65);

Try it online!

Ungolfed:

fun f 90 = ""
  | f  n = implode(map chr[n,n+1,n,32]) ^ f(n+1);

print(f 65);
\$\endgroup\$
0
\$\begingroup\$

VBA, 40 Bytes

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

For i=65To 89:a=Chr(i):?a;Chr(i+1)a:Next
\$\endgroup\$
0
\$\begingroup\$

Acc!!, 66 bytes

Count i while i-25 {
	i+65
	Write _
	Write _+1
	Write _
	Write 0
}

Try it online!

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

ReRegex, 50 bytes

>Z//>(.)(.)/$1$2$1 >$2/>ABCDEFGHIJKLMNOPQRSTUVWXYZ

Outputs in the form

ABA BCB CDC...

Try it online!

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

uBASIC, 64 bytes

0ForI=65To89:A$=Left$(Chr$(I),1):?A$;Left$(Chr$(I+1),1);A$:NextI

Try it online!

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

MY-BASIC, 48 bytes

For I=65 To 89
A=Chr(I)
Print A+Chr(I+1)+A;
Next

Try it online!

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

Visual Basic .NET (Mono), 105 bytes

Module M
Sub Main
Dim I,S
For I=65 To 89
S=Chr(I)
Console.WriteLine(S+Chr(I+1)+S)
Next
End Sub
End Module

Try it online!

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

Yabasic, 45 bytes

For I=65To 89
?Chr$(I)+Chr$(I+1)+Chr$(I)
Next

Try it online!

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

Vim, 29 keypresses

:h<_<CR>jjY<C-^>PVUqqy2llpi<CR><Esc>q25@qdj
\$\endgroup\$
0
\$\begingroup\$

PHP, 79 Bytes

Try it online!

Code (recursive function)

function f($l=25){if($l>0){echo chr($l+65).chr($l+64).chr($l+65)."
".f($l-1);}}

Explanation

function f($l=25){         #Running the function 25 times                  
    if($l>0){               
        echo chr($l+65)    #start getting Z
            .chr($l+64)    # Y in the middle
            .chr($l+65)."  # with chr is still less bytes than str_pad
            ".f($l-1);     #call the function with $l-1
                           #in that call we get the line with YXY
                           #the result works because its writen in the
                           #inverted order of the stack :D
    }
}
\$\endgroup\$
0
\$\begingroup\$

Small Basic, 92 bytes

A Script that takes no input and outputs to the TextWindow Object

For I=65To 89
c=Text.GetCharacter(i)
TextWindow.WriteLine(c+Text.GetCharacter(i+1)+c)
EndFor

Try it at SmallBasic.com! Requires IE/Silverlight

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

PHP, 37 bytes

for($i=A;$i<Z;){echo$j=$i++,"$i$j
";}

Try it online!

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

Rockstar, 65 bytes

X's65
while X-90
cast X into C
let X be+1
cast X into N
say C+N+C

Try it here (Code will need to be pasted in)

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

Python 3, 60 bytes

for a in"abcdefghijklmnopqrstuvwxy":print(a+chr(ord(a)+1)+a)

Try it online!

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

Vyxal, 18 bytes

₄‹ʁ(⟨n|n›|n⟩kAİṅ,)

Try it Online!

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

Swift 5.9, 70 bytes

let f={$0%63>0 ?f($0-1333)+String($0,radix:36)+" ":""}
print(f(45358))

A direct Swift port of @Arnauld's JavaScript answer.

\$\endgroup\$
1 2
3

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.