Skip to content

Instantly share code, notes, and snippets.

@yatemmma
Created June 13, 2013 15:40
Show Gist options
  • Save yatemmma/5774731 to your computer and use it in GitHub Desktop.
Save yatemmma/5774731 to your computer and use it in GitHub Desktop.
(function(rows, cols) {
function group(rows, cols, i) {
function xValue(i) {
if (i % cols == 0) {
return Math.min(3, cols);
} else if (i % cols == 1) {
return 1;
}
return 2;
}
function yValue(i) {
if (i <= cols) {
return 0;
} else if (i > (rows - 1) * cols) {
return Math.min(3, cols) * ((rows > 2) ? 2 : 1);
}
return Math.min(3, cols);
}
return xValue(i) + yValue(i);
}
var output = "";
for (var i = 1; i <= rows * cols; i++) {
output += "repeat:" + i + " group:" + group(rows, cols, i) + "<br>";
}
document.body.innerHTML = output;
})(6, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment