I ran into this code golf problem on StackExchange. The premise is that you take in a short string with some wildcard characters (*
) and return all of the possible variations of that string, replacing the wildcards with each letter of the alphabet. Here’s an example the original question gives:
Input:
*e*c*m*
Output:
aeacama aeacamb ... ... ... welcome ... ... zezczmz
After working through some initial attempts, I realized I actually have no idea how I would solve this effectively! I’m not even interested in golfing it anymore, per se, I’m mostly looking to expand my horizons a bit.
I’d love to see some Julian approaches to this, if anyone has any—I’m especially intrigued by things like the functional Haskell solution, since I know Julia leans more functional than some other languages, but I’d love to see anything people can come up with. Could anyone demonstrate some good ways to tackle this problem?