Skip to content

Commit a804c3c

Browse files
authored
Update README.md
updated read me
1 parent 91c7634 commit a804c3c

File tree

1 file changed

+21
-2
lines changed
  • Specialized Areas/Flow Actions/Create an Array of Item Pairs

1 file changed

+21
-2
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
# Shuffle Array Matches
2-
Flow Action: inputs of a List of SysID's and it creates a Shuffled Arrays, Matches of 2 sysIDs
1+
# Random Pair Generator
2+
3+
## Overview
4+
This script generates random pairs from an input array.
5+
It is useful for creating **tournament matches**, **group assignments**, or **randomized pairings**.
6+
7+
The script is structured to run in a scoped execution context (such as **ServiceNow Flow Designer Actions** or **Scripted REST Transforms**) where it accepts `inputs` and `outputs` objects.
8+
9+
---
10+
11+
## How It Works
12+
1. **Shuffle the Input Array**
13+
- Implements the Fisher–Yates algorithm in `shuffleArray()` to randomize the array.
14+
15+
2. **Create Random Pairs**
16+
- Iterates through the shuffled array in steps of two.
17+
- Forms pairs `[item1, item2]`.
18+
- If the array has an odd length, the last item is placed in a single-element array `[item]`.
19+
20+
3. **Return Results**
21+
- The final set of pairs is returned as `outputs.match`.

0 commit comments

Comments
 (0)