A very long Terza Rima

39

2

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.

LiefdeWen

Posted 2017-12-18T13:25:56.297

Reputation: 3 381

4Is a list of lines okay? – totallyhuman – 2017-12-18T16:23:26.547

6

According to https://en.wikipedia.org/wiki/Terza_rima your ending is wrong. It should end with either Z or ZZ.

– Chris – 2017-12-18T18:28:37.077

Can there be additional output beyond the rhyme scheme? This might save me a few bytes. – NK1406 – 2017-12-18T23:02:22.013

@NK1406 Nope sorry. – LiefdeWen – 2017-12-19T07:13:54.583

1@totallyhuman String array is fine. – LiefdeWen – 2017-12-19T07:14:10.807

@Chris I found it here. Which says it can be YZY,

– LiefdeWen – 2017-12-19T07:15:00.460

@LiefdeWen: Huh. Weird. Sadly I don't know which is correct or I'd edit wikipedia to be consistent. :) – Chris – 2017-12-19T17:15:58.007

Related – FlipTack – 2017-12-19T22:22:44.917

@LiefdeWen From your Wiki I see “YZY/Z” or “YZY/ZZ” or “YZY/ZYZ.” No “YZY and that’s it.” – DonielF – 2018-01-02T15:18:09.370

Answers

25

JavaScript (ES6), 51 50 49 bytes

Saved 1 byte thanks to @l4m2

f=(n=45358)=>n%63?f(n-1333)+n.toString(36)+' ':''

Try it online!

How?

We start with n = 45358 (yzy in base-36). We subtract 1333 from n at each iteration (111 in base-36). We stop as soon as n MOD 63 = 0, because 12033 (9a9 in base-36) is the first value for which this condition is fulfilled, and 63 is the smallest modulo with such a property.

Decimal | Base-36 | MOD 63
--------+---------+-------
  45358 |   yzy   |   61
  44025 |   xyx   |   51
  42692 |   wxw   |   41
  41359 |   vwv   |   31
  40026 |   uvu   |   21
  38693 |   tut   |   11
  37360 |   sts   |    1
  36027 |   rsr   |   54
  34694 |   qrq   |   44
  33361 |   pqp   |   34
  32028 |   opo   |   24
  30695 |   non   |   14
  29362 |   mnm   |    4
  28029 |   lml   |   57
  26696 |   klk   |   47
  25363 |   jkj   |   37
  24030 |   iji   |   27
  22697 |   hih   |   17
  21364 |   ghg   |    7
  20031 |   fgf   |   60
  18698 |   efe   |   50
  17365 |   ded   |   40
  16032 |   cdc   |   30
  14699 |   bcb   |   20
  13366 |   aba   |   10
  12033 |   9a9   |    0

Arnauld

Posted 2017-12-18T13:25:56.297

Reputation: 111 334

How did you decide base36? and are you sure its optimal? – LiefdeWen – 2017-12-18T13:38:30.290

2@LiefdeWen It's the lowest base to contain all the letters, so it's optimal. – Erik the Outgolfer – 2017-12-18T13:39:53.607

@user202729 What do you mean? He's not OP, so he's one of those people you refer to? – Erik the Outgolfer – 2017-12-18T13:43:16.533

@EriktheOutgolfer Ok, that's fair. I can't force everyone to put answers into spoiler tag like in puzzling SE. – user202729 – 2017-12-18T13:52:29.587

17As an (un)interesting side-node, 1333 = 666*2+1 and this is my 666th answer on PPCG. – Arnauld – 2017-12-18T14:04:46.727

3@Arnauld please ensure you use the value 1335 somewhere in your next answer. – IanF1 – 2017-12-19T06:46:07.583

f=(n=45358)=>n%63?f(n-1333)+n.toString(36)+' ':'' 1B shorter – l4m2 – 2018-01-02T05:21:51.017

mod 63 andand 62 both work. Order matter – l4m2 – 2018-01-02T21:16:15.020

15

C (gcc), 41 bytes

f(i){for(i='ABA';i%29;i+=65793)puts(&i);}

Try it online!

Fixed and -9 thanks to user202729. -1 thanks to Dennis and -2 thanks to Arnauld too.

Mr. Xcoder

Posted 2017-12-18T13:25:56.297

Reputation: 39 774

45 bytes. – user202729 – 2017-12-18T14:15:13.723

1(i='ABA';i<'ZZZ';i+=65793) saves a byte. – Dennis – 2017-12-18T14:32:56.793

Use 59e5 instead of 'ZZZ' saves another byte. – user202729 – 2017-12-18T15:00:04.203

You can use i%29 for 41 bytes

– Arnauld – 2017-12-18T15:49:24.197

10

Jelly, 7 bytes

ØAṡ2ŒBY

Try it online!

-1 byte thanks to Dennis

ØAṡ2ŒBY  Main Link
ØA       Alphabet
  ṡ2     Slice into overlapping slices of length 2
    ŒB   Palindromize (bounce) each
      Y  Join by newlines

HyperNeutrino

Posted 2017-12-18T13:25:56.297

Reputation: 26 575

9

05AB1E, 5 bytes

Aü«€û

Try it online!

-1 byte thanks to Emigna
-1 byte thanks to rule change; thanks to kalsowerus for pointing that out

Hehe, currently beats Pyth. \o/

Explanation

Aü«€û»  Full Program
A       Lowercase Alphabet
 ü«     Pairwise with merge-list
   €û   For each, palindromize

HyperNeutrino

Posted 2017-12-18T13:25:56.297

Reputation: 26 575

You could do Aü«€û» – Emigna – 2017-12-18T14:10:01.450

@Emigna O cool, thanks! :D – HyperNeutrino – 2017-12-18T14:11:55.773

Nice, that's what I got too without looking. – Magic Octopus Urn – 2017-12-19T15:00:03.427

According to the comments, a list of strings is fine as output, you can remove the join. – kalsowerus – 2017-12-20T14:24:51.493

9

brainfuck, 51 48 bytes

Saved 3 bytes thanks to @ovs.

++++++++[>+>+++>++++++++<<<-]>++>+[->+.+.-.<<.>]

Try it online!

Explanation

INITIALIZE TAPE:

0000:           (none)
0001: C_NEWLINE (10)
0002: V_COUNT   (25)
0003: V_ALPHA   (64)
++++++++[>+>+++>++++++++<<<-]>++>+

V_COUNT TIMES:              [-
    INCREMENT V_ALPHA         >+
    PRINT V_ALPHA             .
    PRINT V_ALPHA PLUS ONE    +.
    PRINT V_ALPHA             -.
    PRINT C_NEWLINE           <<.
END LOOP                    >]

Conor O'Brien

Posted 2017-12-18T13:25:56.297

Reputation: 36 228

@ConorO'Brien - I just noticed that my answer is pretty similar to yours. Please feel free to comment if you think it is too close and I'll remove it. – ElPedro – 2017-12-18T15:49:10.490

1@ElPedro No, you're fine, there isn't much room for innovation in this challenge :) – Conor O'Brien – 2017-12-18T17:16:11.303

9

brainfuck, 51 49 bytes

+++++[>+++++>+++++++++++++>++<<<-]>[>.+.-.+>.<<-]

Try it online!

An attempt at an explanation...

+++++                     #Put 5 in cell 0 because that is the highest common denominator of 10, 65 and 25
[                         #Start loop
>+++++                    #Counter in cell 1 is 25 (How many lines we must print)
>+++++++++++++            #Counter in cell 2 is 65 (ASCII A)  
>++                       #Counter in cell 3 is 10 (Newline)
<<<-]                     #Decrement the outer counter until the cells have the right values (muliples of 5).
>                         #Move to the counter that says how many lines we must print.
[>.                       #Print the character in cell 2
+.                        #Add one to the character in cell 2 and print it
-.                        #Subtract one from the character in cell 2 and print it
+                         #Add one to the character in cell 2 for the next loop
>.                        #Print a new line
<<-]                      #Decrement cell 1 and run again until cell 1 is 0

-2 with thanks to @ovs

My first attempt at brainfuck so any hints gratefully received. If I was more experienced with it then I am sure I could shave a few more bytes off but I only got into it yesterday.

ElPedro

Posted 2017-12-18T13:25:56.297

Reputation: 5 301

-1 byte – Jo King – 2018-02-01T00:42:56.773

7

APL (Dyalog), 14 bytes

25↑0 1 0⊖3/⍪⎕A

Try it online!

Please note that the added ⎕← is for TIO to output the text and is not normally required.

Erik the Outgolfer

Posted 2017-12-18T13:25:56.297

Reputation: 38 134

7

Python 2, 42 41 bytes

-1 byte thanks to Halvard Hummel

i=65;exec"print'%c'*3%(i,i+1,i);i+=1;"*25

Try it online!

Rod

Posted 2017-12-18T13:25:56.297

Reputation: 17 588

6

Charcoal, 11 bytes

E²⁵✂αι⁺²ι‖O

Try it online! Link is to verbose version of code. Explanation:

 ²⁵         Literal 25
E           Map over implicit range
    α       Predefined uppercase letters
   ✂ ι⁺²ι   Slice 2 characters
            Implicitly print result on separate lines
         ‖O Reflect with overlap

Neil

Posted 2017-12-18T13:25:56.297

Reputation: 95 035

6

Brain-Flak, 90 bytes

((((()()()){}){}){}()){(({})<((({}((((()()()()){}){}){}){})())[()])((()()()()()){})>[()])}

Try it online!

One reason this is shorter than the other brain-flak answer is because it uses uppercase instead of lowercase characters, which have smaller ASCII values, and are therefore easier to push.

Explanation:

#Push 25
((((()()()){}){}){}())

#While true
{

    #Keep track of the number on top of the stack...
    # We'll call it 'a'
    (({})

        #Push A +...
        <((({}

        # 64 (push)
        ((((()()()()){}){}){}){})
        # + 1 (push)
        ())
        # - 1 (push)
        [()])

        # Push 10
        ((()()()()()){})>

    # Now that's all pushed, we push a - 1 to decrement the loop counter
    [()])

# Endwhile
}

James

Posted 2017-12-18T13:25:56.297

Reputation: 54 537

I write the first version and get no upvotes you write a golf version and get +5. ??? – Christopher – 2017-12-19T00:30:11.723

5

><>, 25 24 23 22 bytes

Saved 2 bytes thanks to Jo King

"!;::o1+:o$oao:'Y')0.A

Try it online!

Emigna

Posted 2017-12-18T13:25:56.297

Reputation: 50 798

23 bytes by removing a quote – Jo King – 2018-01-02T15:36:19.403

Another byte – Jo King – 2018-01-31T23:54:55.697

@JoKing: Thanks again! – Emigna – 2018-02-01T07:04:08.267

5

R, 51 47 bytes

L=LETTERS;cat(sprintf("%s%s%1$s",L[-26],L[-1]))

Output:

> L=LETTERS;cat(sprintf("%s%s%1$s",L[-26],L[-1]))
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

plannapus

Posted 2017-12-18T13:25:56.297

Reputation: 8 610

The naive way without fancy sprintf is 49 bytes

– Giuseppe – 2017-12-18T16:05:01.950

@Giuseppe that would be because i didn't use sprintf correctly :) – plannapus – 2017-12-18T16:24:23.747

OK, but I found a 40 byter :)

– Giuseppe – 2017-12-18T16:51:04.897

@Giuseppe ouch :) – plannapus – 2017-12-18T16:51:50.323

1another [40 byter][https://tio.run/##K/r/PzmxRCMzryQkP7QkzUKjKCkzL0WjwkbXzNTKwlKnQttQp0LH0EBTU/P/fwA] based on converting ASCII codes, in case – NofP – 2017-12-19T09:08:37.863

@Giuseppe you probably should post it as a concurrent answer! NofP: you too! – plannapus – 2017-12-19T09:13:49.830

@NofP not sure if you got notified, so I'm tagging you in this; and notifying plannapus that I've posted my solution as well. – Giuseppe – 2017-12-19T14:59:33.853

5

Befunge-98 (FBBI), 27 23 21 bytes

-4 bytes thanks to James Holderness

j'@1+3k:,1+,,a,'Y/!1+

Try it online!

ovs

Posted 2017-12-18T13:25:56.297

Reputation: 21 408

5

Java 8, 132 85 62 60 Bytes

  • 47 bytes thanks to Neil
  • 26 bytes thanks to Oliver
  • 3 bytes and much better formatting thanks to Kevin
  • Error fixed by Oliver

Golfed

a->{for(char i=64;++i<90;)System.out.println(""+i+++i--+i);}

Ungolfed

public class TerzaRima {
    interface A{
        void a(String a);
    }
    static A a = a -> {
        for (char i = 64; ++i < 90; ) System.out.println("" + i++ + i-- + i);
    };
    public static void main(String[] args){
        a.a(null);
    }
}

DevelopingDeveloper

Posted 2017-12-18T13:25:56.297

Reputation: 1 415

1Printing a char array would probably be a lot shorter. – Neil – 2017-12-18T16:21:45.147

Thanks @Neil, didn't even think about that – DevelopingDeveloper – 2017-12-18T16:27:23.227

1Can you make i a char too? – Neil – 2017-12-18T16:28:06.763

2a->{for(char c=64;++c<90;)System.out.println(""+c++ +c--+c);} (62 bytes) – Olivier Grégoire – 2017-12-18T17:32:10.053

2

Currently this is a snippet instead of a function or program, so you'll have to add the v->{...} as mentioned above by @OlivierGrégoire. (In case you don't know how Java 8 lambdas work, I made an explanation once before.) Also, you can remove the brackets of the loop like Olivier did, and as additional golf you can change the print to System.out.print(" "+i+++i--+i); (a space instead of a new-line, and you don't need the space at c+++c--+c). Try it here.

– Kevin Cruijssen – 2017-12-19T08:20:39.910

@KevinCruijssen sorry, I made this without testing, hence the extraneous space I thought was mandatory. And indeed a lambda is required instead of a pure snippet. However no leading whitespace is allowed so I would reuse the println instead of print with a leading whitespace. – Olivier Grégoire – 2017-12-19T12:35:13.567

1Thanks @KevinCruijssen for the tips as well as the java lambdas document. That was a very easy to follow guide to implement some simple lambdas. I have updated accordingly! – DevelopingDeveloper – 2017-12-19T17:10:04.820

@DevelopingDeveloper only trailing spaces/lines are allowed, not leading spaces. The fix is to use println: v->{for(char i=64;++i<90;)System.out.println(""+i+++i--+i);}

– Olivier Grégoire – 2017-12-21T09:43:21.530

@OlivierGrégoire Thanks for catching that and the quick fix! – DevelopingDeveloper – 2017-12-21T20:21:23.323

4

Husk, 9 bytes

ẊS:`e…"AZ

Try it online!

Erik the Outgolfer

Posted 2017-12-18T13:25:56.297

Reputation: 38 134

4

brainfuck, 41 bytes

-[[<+>--->++>>>+<<<<]>+]>>>[<<.+.-.+>.>-]

Try it online!

ovs

Posted 2017-12-18T13:25:56.297

Reputation: 21 408

+1 I follow most of it but it starts with -[ Does that mean you are setting cell 0 to -1 before you start the loop? Any chance of an explanation for a brainfuck newbie if you have time? Btw, thanks for the -2 on my effort. – ElPedro – 2017-12-21T18:41:22.837

@ElPedro this depends on the brainfuck interpreter, the interpreter at tio.run stores unsigned 8-bit numbers in each cell, so the first cell gets 255 before the loop. – ovs – 2017-12-21T18:47:10.093

@ElPedro the initialization segment is actually generated by BF-Crunch.

– ovs – 2017-12-21T18:51:05.717

4

brainfuck, 45 37 bytes

+[[<+>>++<-]>]<<---[-----<+.+.-.<.>>]

Try it online!

Prints in uppercase, separated by spaces with a trailing space.

How it Works:

+[[<+>>++<-]>] Intialises the tape with the format n^2
               1 2 4 8 16 32 64 128 0 0'
<<---          Navigates to the desired section and tweaks the counter
               1 2 4 8 16 32 64 125<
[-----<+.+.-.<.>>] Prints the Terza Rima, using:
                 125 as the loop counter (decremented by 5 each loop)
                 64 as the current alphabetic character (incremented and printed each loop)
                 32 as the space character

Jo King

Posted 2017-12-18T13:25:56.297

Reputation: 38 234

1This is actually really nice! Good job! – Dust – 2018-04-21T10:17:51.357

3

Pyth, 7 bytes

jC[GtGG

Try it here!

Hehe, currently beats Jelly. \o/

Easily translates to the follwong 05ab1e program:

05AB1E, 7 bytes

AA¦A)ø»

Try it online!

Mr. Xcoder

Posted 2017-12-18T13:25:56.297

Reputation: 39 774

3

Haskell, 28 bytes

[[x,succ x,x]|x<-['A'..'Y']]

Try it online!

succ is such an unfortunate naming choice...

Explanation

[[x,succ x,x]|x<-['A'..'Y']]

[            |x<-          ]  -- for x in...
                 ['A'..'Y']   -- the alphabet sans Z
 [x,succ x,x]                 -- construct a string of x, the successor of x and x

totallyhuman

Posted 2017-12-18T13:25:56.297

Reputation: 15 378

4I do not feel like it is completely fair to return a list of strings instead of separating them with space or newline as required. – user28667 – 2017-12-18T16:13:07.257

@user28667 It's usually allowed in challenges (it probably should be on the Default IO post, if it's not already). The OP is yet to respond in this challenge specifically. This is, however, no reason to downvote. – totallyhuman – 2017-12-18T22:06:40.290

@totallyhuman At the moment the challenge explicitly specifies that either spaces or newlines should be used to separate the output, thus this answer is currently invalid. So strictly according to the site rules it should be deleted, or just fixed by prepending a unlines or unwords. – Laikoni – 2017-12-18T22:14:24.760

@Laikoni I seem to have ninja'd you. The challenge doesn't explicitly deny a list of lines as output. (Plus, that would invalidate a fair amount of answers.) Either way, the answer is now not invalid. – totallyhuman – 2017-12-18T22:18:11.177

3

J, 15 bytes

u:2$~&3\65+i.26

Try it online!

FrownyFrog

Posted 2017-12-18T13:25:56.297

Reputation: 3 112

1This is a tricky way to make a palindrome! – Galen Ivanov – 2017-12-18T16:53:36.567

3

PowerShell, 39 37 bytes

65..89|%{-join[char[]]($_,++$_,--$_)}

Try it online!

Loops from 65 to 89. Each iteration, we're constructing an integer array of (the current, one more, and the current) of the current digit, using pre-increment and pre-decrement. That's then re-cast as a char-array, and -joined together into a single string. Each string is left on the pipeline and an implicit Write-Output at program completion gives us a newline between each element for free.


Alternatively, same byte count

65..89|%{-join[char[]]($_,($_+1),$_)}

Try it online!

AdmBorkBork

Posted 2017-12-18T13:25:56.297

Reputation: 41 581

1($_,($_+1),$_) is an alternative same-length tuple – Veskah – 2018-07-18T02:16:17.460

3

Haskell, 34 32 31 bytes

Based on totallyhuman's answer. -1 byte thanks to H.PWiz

do x<-['A'..'Y'];x:succ x:x:" "

Try it online!

user28667

Posted 2017-12-18T13:25:56.297

Reputation: 579

2save a byte with do – H.PWiz – 2017-12-18T18:10:18.953

3

Brain-Flak, 180 bytes

(()()())(({}){})(({}){})(({}){})(({}){})(({}){}())<>(()()()()())(({}){})(({}){})(()()()()(){}){({}[()])<>(({}))(({}()))(({}[()]))({}()<(()()()()()()()()()())>)<>}<>{}{}{({}<>)<>}<>

Try it online!

Thanks to DJ for getting this working

Christopher

Posted 2017-12-18T13:25:56.297

Reputation: 3 428

3

R, 40 36 bytes

cat(paste0(L<-LETTERS,L[-1],L)[-26])

Try it online!

An alternative to plannapus' answer; this turns out to be a bit golfier; I've posted it per his request.

See also this 40 byte answer by NofP which is quite nice.

Giuseppe

Posted 2017-12-18T13:25:56.297

Reputation: 21 077

3

R, 40 bytes

cat(intToUtf8(rbind(x<-65:89,x+1,x,10)))

Try it online!

One more alternative in R to Plannapus and Giuseppe's answers. Posted following their request. This solution uses ASCII code to UTF8 coding.

PS if TABs were allowed, one could replace the newline (ASCII code 10) with a tabulation (ASCII code 9), and the solution could shrink to 39 bytes:

cat(intToUtf8(rbind(x<-65:89,x+1,x,9)))

NofP

Posted 2017-12-18T13:25:56.297

Reputation: 754

I think using 9 is perfectly fine, since it's whitespace, which is allowed by the OP. – Giuseppe – 2018-04-20T13:40:25.063

3

Pepe, 59 56 bytes

-3 bytes thanks to u_ndefined

REeEeEEeEerEeEeeeeeERrEEEEErEEEeeREEreeerEEEEEeeEreeERee

Try it online!

Explanation:

# Prepare stacks

  # prepare stack R [Z]
  REeEeEEeEe  # push Z

  # prepare stack r [A,B,A]
  rEeEeeeeeE  # push A
  RrEEEEE     # copy and increment A (getting B)
  rEEEee      # duplicate A to end

# Start loop
REE           # create label Z

  reee        # output stack r contents
  rEEEEEeeE   # increment all

  reeE        # end line

Ree           # loop while r[p] != Z

RedClover

Posted 2017-12-18T13:25:56.297

Reputation: 719

1Replacing rEeEeeeeEe with RrEEEEE saves off 3 bytes – u_ndefined – 2018-08-06T10:41:16.453

@u_ndefined Thanks! I made this code before flags were added to Pepe. Updated the answer. – RedClover – 2018-08-06T11:02:03.213

2

J, 18 16 bytes

2(,{.)\u:65+i.26

Changed a.{~ to u: after Conor O'Brien's and FrownyFrog's solutions

Try it online!

Galen Ivanov

Posted 2017-12-18T13:25:56.297

Reputation: 13 815

1Alternative 16 byte: u:(i.25)+/66-#:5 – FrownyFrog – 2017-12-18T18:00:14.473

2

Befunge, 26 bytes

:"A"+:,:1+,,1+:64*`#@_55+,

Try it online!

James Holderness

Posted 2017-12-18T13:25:56.297

Reputation: 8 298

1

Retina, 24 bytes


ABA
;{:G`
T`_p`p`[^Y]..

Try it online!

Martin Ender

Posted 2017-12-18T13:25:56.297

Reputation: 184 808

21 bytes but suffers from trailing newlines... – Neil – 2017-12-18T14:57:47.550

@Neil Yeah, you don't even need the \...`. Getting rid of those trailing newlines is really annoying though. I'm hoping to make printing in loops a bit more flexible and convenient in Retina 1.0. – Martin Ender – 2017-12-18T15:13:12.867

1

Perl 5, 27 24 bytes

say$\=$_++,$_.$\for A..Y

previous solution

say$_,chr 1+ord,$_ for A..Y

Try it online

Nahuel Fouilleul

Posted 2017-12-18T13:25:56.297

Reputation: 5 582

1

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

streetster

Posted 2017-12-18T13:25:56.297

Reputation: 3 635

1

MATL, 12 11 10 bytes

1 byte off thanks to Luis Mendo, by using 5B (5 in binary) to push a [1 0 1] pattern.

66:90!5B-c

Try it online!

Sanchises

Posted 2017-12-18T13:25:56.297

Reputation: 8 530

1

brainfuck, 73 bytes

+++++++++++++[>+++++>+++++<<-]>>+<<<<+++++[>++>+++++<<-]>>[>.>.+<.+<-<.>]

Try it online!

HyperNeutrino

Posted 2017-12-18T13:25:56.297

Reputation: 26 575

1

T-SQL 189 154 bytes

declare @ char(26)='ABCDEFGHIJKLMNOPQRSTUVWXYZ',@i int=1,@@ char while(@i<26)begin  set @@=substring(@,@i,1)print @@+substring(@,@i+1,1)+@@ set @i=@i+1 end

Nelz

Posted 2017-12-18T13:25:56.297

Reputation: 321

1

Recursiva, 13 bytes

{B25"PpZ~}(;}

Try it online!

officialaimm

Posted 2017-12-18T13:25:56.297

Reputation: 2 739

1

J (repl), 18 bytes

u:65+(,>:,])"+i.25

Try it online!

Can be made into a function for +4 bytes:

(u:65+(,>:,])"+i.25)"_

Other solutions:

u:|:65 66 65+/i.25

Explanation

u:65+(,>:,])"+i.25
              i.25     range [0, 25)
     (     )"+         on each number:
      ,  ,               create a list composed of the number,
       >:                the number + 1
          ]              and the number
                       this gives the 2D list [0 1 0] [1 2 1] ...
  65+                  add 65 to each element
u:                     convert to characters

Conor O'Brien

Posted 2017-12-18T13:25:56.297

Reputation: 36 228

1

Batch, 99 bytes

@set s=ABCDEFGHIJKLMNOPQRSTUVWXYZ
:l
@echo %s:~0,2%%s:~0,1%
@set s=%s:~1%
@if not %s%==Z goto l

Only 10 bytes shorter than a literal...

Neil

Posted 2017-12-18T13:25:56.297

Reputation: 95 035

1

Kotlin, 42 bytes

{('A'..'Y').map{println("$it${it+1}$it")}}

Try it online!

or

{('A'..'Y').map{println(""+it+(it+1)+it)}}

Try it online!

ovs

Posted 2017-12-18T13:25:56.297

Reputation: 21 408

1

Add++, 46 44 bytes

L,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"dBREpBR2DBcEJn

Try it online!

Who needs all these "palindromise" functions?

2 bytes saved thanks to DLosc!

How it works (old version)

L,     - Create a nilary lambda function.
  "…"  - Push the uppercase alphabet;     STACK = ['ABC…XYZ']
  d    - Duplicate;                       STACK = ['ABC…XYZ' 'ABC…XYZ']
  BR   - Reverse;                         STACK = ['ABC…XYZ' 'ZYX…CBA']
  2D   - Duplicate from below;            STACK = ['ABC…XYZ' 'ZYX…CBA' 'ABC…XYZ']
  Ep   - Dequeue each;                    STACK = ['BCD…XYZ' 'YXW…CBA' 'BCD…XYZ']
  $BR$ - Reverse the middle string;       STACK = ['BCD…XYZ' 'ABC…WXY' 'BCD…XYZ']
  Bc   - Zip;                             STACK = [['A' 'B' 'A'] … ['Y' 'Z' 'Y']]
  EJ   - Join each;                       STACK = ['ABA' … 'YZY']
  n    - Join with newlines               STACK = ['ABA…YZY']

caird coinheringaahing

Posted 2017-12-18T13:25:56.297

Reputation: 13 702

@DLosc Ohh, nice. Thanks! – caird coinheringaahing – 2017-12-18T21:23:19.760

1

Shnap, 35 bytes

for c:'A'..'Z'println(""+c+(c+1)+c)

Try it online!

Socratic Phoenix

Posted 2017-12-18T13:25:56.297

Reputation: 1 629

1

Brain-Flak classic, 160 150 118+2=120 bytes with -A flag

((((((()()()){}){}){}){}){}())<>(((((()()()()())){}){}){}){({}[])<>([{}])[({}())][({}[])]({}())[((()()()()()){})]{}<>}

Try it online!

The separator is a newline.

-8 bytes thanks to DJ

-32 bytes thanks to DJ

Christopher

Posted 2017-12-18T13:25:56.297

Reputation: 3 428

The first 50 bytes are rather redundant. in general, rather than doing (...)(({}){}) you can do ((...){}) to save 4 bytes. And of course, this can be nested several times. To push 'a' I would do ((((((()()()){}){}){}){}){}()) instead. – James – 2017-12-19T18:05:36.300

You can also use https://brain-flak.github.io/integer/ to autogolf large integers for you.

– James – 2017-12-19T18:05:49.333

And minus 32 bytes

– James – 2017-12-19T18:08:25.923

@DJMcMayhem thanks – Christopher – 2017-12-19T18:28:02.697

1

Japt, 11 6 bytes

Returns an array of lines.

;BäÈiZ

Try it


Explanation

  • ;B is the uppercase alphabet.
  • äÈ gets each pair of consecutive characters in a string and passes them through a function.
  • iZ prepends the current element to the first character of the current element.

Alternative, 6 bytes

;Bã mê

Try it


Explanation

  • ã splits the alphabet string into an array of consecutive character pairs.
  • m maps over the array.
  • ê palindromises the current element.

Shaggy

Posted 2017-12-18T13:25:56.297

Reputation: 24 623

Array of lines is allowed. – LiefdeWen – 2017-12-19T07:16:45.997

1

Pushy, 9 bytes

Z1Z25:QKh

Try it online!

Explanation:

Z1Z          \ Make the stack [0, 1, 0]
   25:       \ 25 times do:
      Q      \    Print the stack, as indexes into the uppercase alphabet
       Kh    \    Increment all values

FlipTack

Posted 2017-12-18T13:25:56.297

Reputation: 13 242

1

Ruby, 32 bytes

puts (?A..?Y).map{|c|c+c.next+c}

Try it online!


If a list of strings is valid output:

Ruby, 31 bytes

->{(?A..?Y).map{|c|c+c.next+c}}

Try it online!

Nnnes

Posted 2017-12-18T13:25:56.297

Reputation: 395

1

V, 16 bytes

¬azòóˆˆ/±²±\r²òd

Try it online!

Hexdump:

00000000: ac61 7af2 f388 882f b1b2 b15c 72b2 f264  .az..../...\r..d

Recursive Regular Expressions for the win!

James

Posted 2017-12-18T13:25:56.297

Reputation: 54 537

1

Clean, 60 bytes

import StdEnv
t=foldr(+++)""[{c,c+one,c,' '}\\c<-['a'..'y']]

Try it online!

If a list of Char ([Char]) is okay instead of a String ({#Char}) (they look the same when printed bare), then we can save a few bytes and use:

Clean, 53 bytes

import StdEnv
t=flatlines[[c,c+one,c]\\c<-['a'..'y']]

Try it online!

If a list of String ([{#Char}]) representing the lines is acceptable, then we can save even more and use:

Clean, 45 bytes

import StdEnv
t=[{#c,c+one,c}\\c<-['a'..'y']]

Try it online!

Οurous

Posted 2017-12-18T13:25:56.297

Reputation: 7 916

1

Funky, 38 bytes

fori=65i<90i++print("%c%c%c"%{i i+1i})

Naïve solution, not very exciting, but it works.

Try it online!

ATaco

Posted 2017-12-18T13:25:56.297

Reputation: 7 898

1

dc, 24 bytes

65[ddP1+dPrPdAP90>M]dsMx

Try it online!

Pretty straightforward. Start with ASCII value for A, duplicate it a couple of times, print it, increment it and duplicate this, print it, swap the top-of-stack, print (the unincremented number), print a line feed, keep going as long as we haven't made it to Z (90).

brhfl

Posted 2017-12-18T13:25:56.297

Reputation: 1 291

1

Python 3, 55 bytes

' '.join(map(lambda x:"%c"*3%(x-1,x,x-1),range(66,91)))

Try it online!

Max00355

Posted 2017-12-18T13:25:56.297

Reputation: 151

1

PHP, 72 bytes

-2 bytes because yay assumed values!

-15 bytes thanks to Francisco Hahn

<?php $x=ABA;for($i=0;$i<75;$i++){if($i%3==0){echo$x." ";}$t=$x[$i%3];$x[$i%3]=++$t;}?>

Try it online!

Takes the string "ABA" through a for loop which loops through each character and increments it. Displays the current value of the string every 3 times.

NK1406

Posted 2017-12-18T13:25:56.297

Reputation: 739

$x=ABA;for(;$i<75;$i++){echo($i%3)?"":$x." ";$t=$x[$i%3];$x[$i%3]=++$t;} 72 – Francisco Hahn – 2018-05-08T13:42:13.653

1

Premier, 18 bytes

:| s |ns:'Z~*AUc
A

Try it online!

Explanation

The second line just defines the data for the program. So, starting wtih A on the stack...

:| s |ns:'Z~*AUc
:|   |n            print the following format:
  .                   TOS
   s                  TOS + 1
    .                 TOS
                   this prints out ABA, for example
       s:'Z~*      If the next char is not 'Z'
             A        append it to the data
              Uc   print a newline

This repeats until the next character is Z, at which point there is no data left, and the program terminates.

Conor O'Brien

Posted 2017-12-18T13:25:56.297

Reputation: 36 228

1

vim, 48 28 keystrokes

:h<_EnterjjYZZPqqy2llpi ESCl@qq@qD

My first attempt at golfing in vim

Explanation

:h<_EnterjjYZZP                    Insert the alphabet by copying it from the help manual
qq                                  Define a macro `q`:
 y2l                                 Copy the first two characters (relative to the cursor)
 lp                                  Paste after the copied characters (ABCDE -> ABABCDE)
 i Esc                             Insert a space (ABABCDE -> ABA BCDE)
 l@q                                 Run the macro again with the cursor after the space
q@q                                 End the macro defenition and run it
D                                   Remove the last Z

Herman L

Posted 2017-12-18T13:25:56.297

Reputation: 3 611

1

Go, 56 Bytes

func n(){for i:=65;i<90;i++{Printf("%c%c%c\n",i,i+1,i)}}

Ungolfed and readable:

func n() {
    for i := 65; i < 90; i++ {
        Printf("%c%c%c\n", i, i + 1, i)
    }
}

Try it online!

Dust

Posted 2017-12-18T13:25:56.297

Reputation: 131

1

Go, 60 56 bytes

func t(){for i:=65;i<90;i++{Printf("%c%c%c\n",i,i+1,i)}}

Try it online!

ollien

Posted 2017-12-18T13:25:56.297

Reputation: 151

1

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

user85052

Posted 2017-12-18T13:25:56.297

Reputation:

1

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

sporeball

Posted 2017-12-18T13:25:56.297

Reputation: 461

0

dzaima

Posted 2017-12-18T13:25:56.297

Reputation: 19 048

0

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

Laikoni

Posted 2017-12-18T13:25:56.297

Reputation: 23 676

0

SNOBOL4 (CSNOBOL4), 83 82 81 79 72 bytes

R	&UCASE POS(I) LEN(1) . L @I LEN(1) . R	:F(END)
	OUTPUT =L R L	:(R)
END

Try it online!

I think I'm finally getting the hang of @!

SNOBOL variables are initialized automatically to "" which is also equivalent to 0. So the first time the interpreter sees line R, the line is:

&UCASE POS(0) LEN(1) . L @I LEN(1) . R  :F(END)

which finds a LENgth 1 string starting at POSition 0 (the beginning of the string), assigning the matched string to L. Then we assign the position of that match to I using @, which has been incremented by 1 because of the LEN(1) . L. The next character is then matched and assign it to R, and output L R L. This continues until I is 25, since then LEN(1) . R fails to match, as L would be Z.

Giuseppe

Posted 2017-12-18T13:25:56.297

Reputation: 21 077

0

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

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

Acc!!, 66 bytes

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

Try it online!

FantaC

Posted 2017-12-18T13:25:56.297

Reputation: 1 425

0

Cubically, 34 bytes

FRF'-2(+345@+33-5@-33+5@-33200@1)6

Try it online!

It was hard... At least it's doable. (without too much hardcoding)

Other Rubik's algorithm may lead to shorter sequence.

Some alternatives I tried (which is, unfortunately, longer):

35 bytes: Try it online!

36 bytes: Try it online!


Explanation:


FRF'      Rubik's cube algorithm. This algorithm has the property of make face
          value 1 equal to 10. (character of code of `\n`)
-2        Subtract face value 2 (which is 25) from the notepad.
(    )6   While notepad is nonzero:
+345        Add 90 to notepad.
@           Print notepad value.
+33-5       Add 1 to notepad.
@           Print notepad value.
-33+5       Subtract 1 from notepad.
@           Print notepad value.
-33200      Subtract 89 from notepad.
@1          Print face value 1 (which is 10, '\n')

user202729

Posted 2017-12-18T13:25:56.297

Reputation: 14 620

0

ReRegex, 50 bytes

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

Outputs in the form

ABA BCB CDC...

Try it online!

ATaco

Posted 2017-12-18T13:25:56.297

Reputation: 7 898

0

uBASIC, 64 bytes

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

Try it online!

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

MY-BASIC, 48 bytes

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

Try it online!

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

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!

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

Yabasic, 45 bytes

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

Try it online!

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

Vim, 29 keypresses

:h<_<CR>jjY<C-^>PVUqqy2llpi<CR><Esc>q25@qdj

BlackCap

Posted 2017-12-18T13:25:56.297

Reputation: 3 576

0

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
    }
}

Francisco Hahn

Posted 2017-12-18T13:25:56.297

Reputation: 591

0

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

Taylor Scott

Posted 2017-12-18T13:25:56.297

Reputation: 6 709

0

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

streetster

Posted 2017-12-18T13:25:56.297

Reputation: 3 635

0

Python 3, 49 bytes

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

Try it online

RGS

Posted 2017-12-18T13:25:56.297

Reputation: 5 047