sub interleave { # PNAMBIC; I'm just making two arrays using length args @a = split //, "A" x shift; @b = split //, "B" x shift; # Some magic happens here with @$a and @$b } #### # These are just demonstrator edge cases interleave(1, 1); AB interleave(2, 1); ABA ### This is the good stuff interleave(1, 2); ABB # BAB and BBA are also fine interleave(2, 2); ABBA interleave(3, 3); ABABBA # ABBABA is also fine interleave(4, 14); ABBBBABBBBBABBBBBA # 'B' strings can be swapped around interleave(7, 4); ABABABABAAA