Skip to content

Instantly share code, notes, and snippets.

@trandaison
Created May 16, 2019 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trandaison/8c2a2c527aa1bea02b6aa73d100f4300 to your computer and use it in GitHub Desktop.
Save trandaison/8c2a2c527aa1bea02b6aa73d100f4300 to your computer and use it in GitHub Desktop.
const generateArrays = (limit = 600, arraySize = 36, min = 1, max = 99) => {
let currentIndex = max - arraySize + 2;
const result = [];
while (result.length < limit) {
const initArray = [null];
const nextIndex = currentIndex + (arraySize - 1);
for (let i = currentIndex; i <= nextIndex; i++) {
initArray.push(i);
}
for (let i = min; i < currentIndex; i++) {
const array = [...initArray];
array[0] = i;
if (result.length < limit) {
result.push(array);
}
}
currentIndex -= 1;
}
return result;
};
// generateArrays(600, 36, 1, 99);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment