Or if the regexp engine manages to do that automatically.
[UPDATE: it is slower to provide your own max length. the perl regexp engine is badass. repeating timings on my mac pro with a target_length of 12 show the plain {2,} version is 15% quicker].
(also, you've a minor typo as you recurse into "generate" instead of "solutions", I assume b/c you renamed the function at the very end to make the eg: code scan better).
The challenge calls for sequences "such that no two immediately adjacent subsequences are equal".
This, to me, implies subsequences of any length > 1.
For a $target_length of 5, your solution is correct as 2 is the longest repeatable subsequence.
Easy fix, of course:
becomes I wonder if it would help performance to say: Or if the regexp engine manages to do that automatically.[UPDATE: it is slower to provide your own max length. the perl regexp engine is badass. repeating timings on my mac pro with a target_length of 12 show the plain {2,} version is 15% quicker].
(also, you've a minor typo as you recurse into "generate" instead of "solutions", I assume b/c you renamed the function at the very end to make the eg: code scan better).