File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Specialized Areas/Flow Actions/Create an Array of Item Pairs Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ (function execute(inputs, outputs) {
2+ function shuffleArray(array) {
3+ for (var i = array.length - 1; i > 0; i--) {
4+ var j = Math.floor(Math.random() * (i + 1));
5+ var temp = array[i];
6+ array[i] = array[j];
7+ array[j] = temp;
8+ }
9+ return array;
10+ }
11+
12+ function createRandomPairs(array) {
13+ var shuffledArray = shuffleArray(array.slice()); // Make a copy of the array and shuffle it
14+ var pairs = [];
15+ for (var i = 0; i < shuffledArray.length; i += 2) {
16+ if (i + 1 < shuffledArray.length) {
17+ pairs.push([shuffledArray[i], shuffledArray[i + 1]]);
18+ } else {
19+ pairs.push([shuffledArray[i]]);
20+ }
21+ }
22+ return pairs;
23+ }
24+
25+
26+ var randomPairs = createRandomPairs(inputs.wheels);
27+
28+
29+
30+ outputs.match = randomPairs;
31+
32+ })(inputs, outputs);
You can’t perform that action at this time.
0 commit comments