Skip to content

Commit

Permalink
test permutations with arrays of arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
conmaster2112 committed Oct 4, 2024
1 parent 8f79d8f commit 93d3806
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/flags/data/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function Task(input, fileName) {
/**
*
* @param {{[key: string]: any[]}} states_map
* @param {{name: string, permutations?: string[], properties: string[], raw_id: number, serialization_id: string}} block_item
* @param {{name: string, permutations?: number[][], properties: string[], raw_id: number, serialization_id: string}} block_item
*/
function MapBlock(states_map, block_item){
const lengths = block_item.properties.map(e=>states_map[e].length);
Expand All @@ -94,12 +94,12 @@ function MapBlock(states_map, block_item){
/**
* @param {number[]} lengths
* @param {number} index
* @returns {Generator<string>}
* @returns {Generator<number[]>}
*/
function * PermutationGenerator(lengths, index){
for (let v = 0; v < lengths[index]; v++) {
if(index > 0) for(const permutations of PermutationGenerator(lengths, index-1)) yield permutations + GetStringFor(v);
else yield GetStringFor(v);
if(index > 0) for(const permutations of PermutationGenerator(lengths, index-1)) yield [...permutations, v];
else yield [v];
}
}
function GetStringFor(num = 0, lengthExpected = 2, r = 16){
Expand Down

0 comments on commit 93d3806

Please sign in to comment.