3 deleted 8 characters in body
source | link

JavaScript 6, 120116 Bytes

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExpy=>y==x[z]||(x+x).match(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExpy=>y==x[z]||(x+x).match(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));

JavaScript 6, 120 Bytes

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExp(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExp(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));

JavaScript 6, 116 Bytes

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]||(x+x).match(y+(q=h[++z]||h[0])+'|'+q+y))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]||(x+x).match(y+(q=h[++z]||h[0])+'|'+q+y))?f(x):h.join``

console.log (f('abcdef'));

2 added 16 characters in body
source | link

JavaScript 6, 113120 Bytes

f=x=>(h=[...x].sort(_=>Math.random(z=0)>-.5)).some((y,z)=>RegExpy=>y==x[z]|RegExp(y+(q=h[z+1]||h[0]q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random(z=0)>-.5)).some((y,z)=>RegExpy=>y==x[z]|RegExp(y+(q=h[z+1]||h[0]q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));

JavaScript 6, 113 Bytes

f=x=>(h=[...x].sort(_=>Math.random()>.5)).some((y,z)=>RegExp(y+(q=h[z+1]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random()>.5)).some((y,z)=>RegExp(y+(q=h[z+1]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));

JavaScript 6, 120 Bytes

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExp(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random(z=0)-.5)).some(y=>y==x[z]|RegExp(y+(q=h[++z]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));

1
source | link

JavaScript 6, 113 Bytes

f=x=>(h=[...x].sort(_=>Math.random()>.5)).some((y,z)=>RegExp(y+(q=h[z+1]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

f=x=>(h=[...x].sort(_=>Math.random()>.5)).some((y,z)=>RegExp(y+(q=h[z+1]||h[0])+'|'+q+y).test(x+x))?f(x):h.join``

console.log (f('abcdef'));