Skip to main content
1 of 2
user avatar
user avatar

JavaScript, 77 bytes

a=>[...a+a].map((_,b)=>a-=-z.substring((b-=n)>0?b:0,b+n),a*=n=(z=a).length)|a

f=a=>[...a+a].map((_,b)=>a-=-z.substring((b-=n)>0?b:0,b+n),a*=n=(z=a).length)|a

console.log(f('123'));
console.log(f('101'));
console.log(f('12'));
console.log(f('1234567'));

user72349