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