Rep-string

var arr = <1001110011 1110111011
           0010010010 1010101010
           1111111111 0100101101
           0100100  101  11 00 1>
Β 
for n (arr) {
    if (var m = /^(.+)\1+(.*$)(?(?{ substr($1, 0, length $2) eq $2 })|(?!))/.match(n)) {
       var i = m[0].len
       say (n.substr(0, i),
            n.substr(i, i).tr('01', 'πŸ˜πŸ™'),
            n.substr(i*2))
    } else {
        say "#{n} (no repeat)"
    }
}

Output:

10011πŸ™πŸ˜πŸ˜πŸ™πŸ™
1110πŸ™πŸ™πŸ™πŸ˜11
001πŸ˜πŸ˜πŸ™0010
1010πŸ™πŸ˜πŸ™πŸ˜10
11111πŸ™πŸ™πŸ™πŸ™πŸ™
0100101101 (no repeat)
010πŸ˜πŸ™πŸ˜0
101 (no repeat)
1πŸ™
0𝟘
1 (no repeat)

Last updated