-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-com.js
More file actions
22 lines (13 loc) · 759 Bytes
/
array-com.js
File metadata and controls
22 lines (13 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Array combinations
// DESCRIPTION:
// In this Kata, you will be given an array of arrays and your task will be to return the number of unique arrays that can be formed by picking exactly one element from each subarray.
// For example: solve([[1,2],[4],[5,6]]) = 4, because it results in only 4 possibilites. They are [1,4,5],[1,4,6],[2,4,5],[2,4,6].
// Make sure that you don't count duplicates; for example solve([[1,2],[4,4],[5,6,6]]) = 4, since the extra outcomes are just duplicates.
// See test cases for more examples.
// Good luck!
// If you like this Kata, please try:
// Sum of integer combinations
// Sum of array singles
function solve(arr) {
return arr.map(unique => new Set(unique).size).reduce((acc, curr) => acc * curr, 1)
};