JSFiddle - React, Tailwind, and code Playground
by joeycakes
HTML
<pre id="output"></pre>
JavaScript
function write (text) {
document.getElementById("output").appendChild(
document.createTextNode(text)
);
}
function writeln (text) {
write(text + "\n");
}
var moves = 0,
arr = [],
len = 52,
step = 2,
stepx = (len / step) - 1;
while (len--) {
arr[len] = len + 1;
}
len = arr.length;
writeln("Starting array: " + arr);
writeln("Step: " + step);
writeln("StepX: " + stepx);
var x, y, items, newarr = [];
for (x = 0; x < stepx; x++) {
writeln(x + ": ");
items = arr.splice(0, step);
for (y = 0; y < items.length; y++) {
newarr.push(items[y])
}
writeln(newarr);
moves++;
}
arr = newarr;
writeln("Moves: " + moves);