Created
June 13, 2013 15:40
-
-
Save yatemmma/5774731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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