(arr)
| 155 | |
| 156 | |
| 157 | function permute(arr) { |
| 158 | let permutations = [] |
| 159 | let n = arr.length |
| 160 | let n_permutations = Math.pow(2, n) |
| 161 | for (let i = 0; i < n_permutations; i++) { |
| 162 | let perm = [] |
| 163 | let mask = Number(i) |
| 164 | .toString(2) |
| 165 | .padStart(n, "0") |
| 166 | |
| 167 | for (let idx = 0; idx < mask.length; idx++) { |
| 168 | if (mask[idx] === "1" && arr[idx].trim() !== "") { |
| 169 | perm.push(arr[idx]) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if (perm.length > 0) { |
| 174 | permutations.push(perm) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return permutations |
| 179 | } |
| 180 | |
| 181 | function permuteNumber(arr) { |
| 182 | return Math.pow(2, arr.length) |
no test coverage detected