Created
June 14, 2020 15:15
-
-
Save YaroslavShapoval/f049dc4219649eacb9e68939cea2687b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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