1
var movesToStamp = function (stamp, target) {7
for (let sz = stamp.length; sz > 0; --sz)8
for (let i = 0; i <= stamp.length - sz; ++i) {11
stamp.slice(i, sz + i) +12
"*".repeat(stamp.length - sz - i); // preparing 'abc', '*bc', 'ab*', 'a**' etc13
let pos = target.indexOf(new_stamp); // finding position of prepared new_stamp in target15
// if position is found16
res.push(pos); // then push position into response array17
turn_stamp += sz; // sz is size on new_stamp without '*'. so for 'abc' sz equals 3, for 'a**' sz equals 119
target.slice(0, pos) +20
"*".repeat(stamp.length) +21
target.slice(pos + stamp.length); // insert new_stamp into target22
pos = target.indexOf(new_stamp); // try to find another place in target where we can insert new_stamp25
total_stamp += turn_stamp;28
return total_stamp == target.length ? res : []; // we check if all characters converted to '*'