Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save YaroslavShapoval/f049dc4219649eacb9e68939cea2687b to your computer and use it in GitHub Desktop.

Select an option

Save YaroslavShapoval/f049dc4219649eacb9e68939cea2687b to your computer and use it in GitHub Desktop.
const ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const N = 9;
const LIST = new Array(N).fill(undefined);
const RESPONSES = [6,4,0,4,0,0,2,1,0];
for (let i = 0; i < N; i++) {
let cur_index = -1;
let free_place_index = 0;
while (free_place_index <= RESPONSES[i]) {
cur_index++;
if (LIST[cur_index] !== undefined) {
continue;
}
free_place_index++;
}
LIST[cur_index] = ALPHABET[i];
console.log(LIST);
}
console.log(LIST.join('').toUpperCase());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment