produce the teddyPattern

0

My youngest son formulated a letter pattern the other day.

For ‘a': ‘a'
For ‘b': ‘ab’ (the pattern for ‘a’, twice, with every other ‘a' replaced with a ‘b'.
For ‘c’: ‘abac’ (the pattern for ‘b', twice, with every other ‘b’ replaced by a ‘c’)
For ‘d’: ‘abacabad’ (the pattern for ‘c’ twice, with every other ‘c’ replaced by a ‘d’.

etc.

Your challenge:

Write code that generates the teddyPattern for any letter up to ‘z’ (the output for which has a length of 33,554,432 characters, ending in a single ‘z’).

Your code can accept either a letter as input, or that letter’s position in the alphabet, at your discretion.

The output should be a string, in lowercase or uppercase at your discretion.

For the sake of comparison, I wrote a version in Mathematica that takes 113 bytes, suggesting somebody is going to do this in about six bytes with a golfing language.

I’ve tagged this as a ‘recursion’ challenge because I suspect a lot of implementations will use recursion, but I’m keen to see what interesting solutions arise from different approaches.

Shortest byte count wins, but I plan to call out interesting or excellent solutions that are more verbose as well.

Michael Stern

Posted 2019-04-01T20:01:21.257

Reputation: 3 029

Question was closed 2019-04-01T20:21:49.860

2

This is a dupe of this one, with the only difference that you only take the first half of the output including the middle character. Also, taking a letter instead of a number is just added complexity.

– Erik the Outgolfer – 2019-04-01T20:05:07.963

No answers