Skip to main content
added 103 characters in body
Source Link
user72349
user72349

JavaScript, 7777 74 bytes

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

Saved 3 bytes thanks to Value Ink

f=a=>[...a+a].map((_,b)=>a-=-z.substringsubstr((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'));
console.log(f('102033'));

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'));

JavaScript, 77 74 bytes

Saved 3 bytes thanks to Value Ink

f=a=>[...a+a].map((_,b)=>a-=-z.substr((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'));
console.log(f('102033'));

Source Link
user72349
user72349

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'));