Random Player Generator

keithrpetty

New Member
Joined
Dec 28, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I am a member of a golf Society with 20 permanent players. We book 5 time slots x 4 players each week (2 pairs). How do I generate a schedule so that each player plays with a different pairing. There will ultimately be 19 weeks before the schedule reverts back to week 1.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I am a member of a golf Society with 20 permanent players. We book 5 time slots x 4 players each week (2 pairs). How do I generate a schedule so that each player plays with a different pairing. There will ultimately be 19 weeks before the schedule reverts back to week 1.
I have an answer, thanks
 
Upvote 0
I went onto golfsoftware.com and chose twosomes, 20 players and 19 events. It generates various number pairings. I allocated 1 - 20 to each player then did a VLookup.
 
Upvote 0
Just for fun I researched a little on how to generate the pairs.
Here is what I came up with:
For any even number n you will get your pairs as expected.
The math behind this I got from here: An efficient approach to combinations of pairs in groups without repetitions?

GolfPairs.xlsx
ABCDEFGHIJKL
1n20
2(n even)
3Pairs
412345678910
5Weeks11 - 23 - 204 - 195 - 186 - 177 - 168 - 159 - 1410 - 1311 - 12
621 - 34 - 25 - 206 - 197 - 188 - 179 - 1610 - 1511 - 1412 - 13
731 - 45 - 36 - 27 - 208 - 199 - 1810 - 1711 - 1612 - 1513 - 14
841 - 56 - 47 - 38 - 29 - 2010 - 1911 - 1812 - 1713 - 1614 - 15
951 - 67 - 58 - 49 - 310 - 211 - 2012 - 1913 - 1814 - 1715 - 16
1061 - 78 - 69 - 510 - 411 - 312 - 213 - 2014 - 1915 - 1816 - 17
1171 - 89 - 710 - 611 - 512 - 413 - 314 - 215 - 2016 - 1917 - 18
1281 - 910 - 811 - 712 - 613 - 514 - 415 - 316 - 217 - 2018 - 19
1391 - 1011 - 912 - 813 - 714 - 615 - 516 - 417 - 318 - 219 - 20
14101 - 1112 - 1013 - 914 - 815 - 716 - 617 - 518 - 419 - 320 - 2
15111 - 1213 - 1114 - 1015 - 916 - 817 - 718 - 619 - 520 - 42 - 3
16121 - 1314 - 1215 - 1116 - 1017 - 918 - 819 - 720 - 62 - 53 - 4
17131 - 1415 - 1316 - 1217 - 1118 - 1019 - 920 - 82 - 73 - 64 - 5
18141 - 1516 - 1417 - 1318 - 1219 - 1120 - 102 - 93 - 84 - 75 - 6
19151 - 1617 - 1518 - 1419 - 1320 - 122 - 113 - 104 - 95 - 86 - 7
20161 - 1718 - 1619 - 1520 - 142 - 133 - 124 - 115 - 106 - 97 - 8
21171 - 1819 - 1720 - 162 - 153 - 144 - 135 - 126 - 117 - 108 - 9
22181 - 1920 - 182 - 173 - 164 - 155 - 146 - 137 - 128 - 119 - 10
23191 - 202 - 193 - 184 - 175 - 166 - 157 - 148 - 139 - 1210 - 11
Hoja3 (3)
Cell Formulas
RangeFormula
C4:L4C4=SEQUENCE(,B1/2)
B5:B23B5=SEQUENCE(B1-1)
C5:L23C5=LET(n,$B$1, i,SEQUENCE(n-1,,0), k,INT((SEQUENCE(,n-2)+1)/2), s,IF(ISODD(SEQUENCE(,n-2)),1,-1), res,HSTACK(EXPAND(1,$B$1-1,,1),i+2,MOD(i+k*s,n-1)+2), rows,WRAPROWS(TOCOL(res),2), pairs,BYROW(rows,LAMBDA(x,CHOOSECOLS(x,1)&" - "&CHOOSECOLS(x,2))), WRAPROWS(pairs,n/2) )
Dynamic array formulas.
 
Upvote 0
Here is the same thing but the order of players each week is random (so it doesn't always start with player 1):

GolfPairs.xlsx
ABCDEFGHIJKL
1n20
2(n even)
3Pairs
412345678910
5Weeks17 - 168 - 156 - 1711 - 129 - 144 - 191 - 210 - 135 - 183 - 20
624 - 27 - 1810 - 151 - 39 - 165 - 208 - 176 - 1912 - 1311 - 14
7313 - 141 - 48 - 195 - 39 - 1812 - 1511 - 166 - 27 - 2010 - 17
841 - 514 - 156 - 412 - 1713 - 167 - 311 - 188 - 29 - 2010 - 19
958 - 411 - 2012 - 1910 - 29 - 314 - 1713 - 1815 - 161 - 67 - 5
10612 - 29 - 515 - 181 - 713 - 208 - 616 - 1711 - 310 - 414 - 19
11717 - 181 - 811 - 513 - 39 - 714 - 215 - 2010 - 616 - 1912 - 4
12814 - 410 - 812 - 615 - 313 - 518 - 1911 - 71 - 917 - 2016 - 2
13913 - 718 - 215 - 511 - 912 - 814 - 617 - 316 - 419 - 201 - 10
141020 - 215 - 717 - 513 - 912 - 1016 - 619 - 314 - 81 - 1118 - 4
151115 - 91 - 1220 - 413 - 1119 - 516 - 814 - 102 - 318 - 617 - 7
16123 - 416 - 101 - 132 - 517 - 915 - 1119 - 720 - 614 - 1218 - 8
17134 - 51 - 1418 - 102 - 719 - 916 - 123 - 617 - 1115 - 1320 - 8
18145 - 617 - 133 - 816 - 1419 - 1120 - 101 - 154 - 72 - 918 - 12
19154 - 91 - 165 - 818 - 143 - 1017 - 156 - 719 - 132 - 1120 - 12
201619 - 154 - 116 - 95 - 1018 - 161 - 1720 - 142 - 137 - 83 - 12
21177 - 101 - 188 - 94 - 133 - 145 - 1219 - 176 - 1120 - 162 - 15
22185 - 142 - 174 - 151 - 197 - 129 - 108 - 116 - 1320 - 183 - 16
23197 - 142 - 194 - 176 - 158 - 135 - 161 - 203 - 1810 - 119 - 12
Random order
Cell Formulas
RangeFormula
C4:L4C4=SEQUENCE(,B1/2)
B5:B23B5=SEQUENCE(B1-1)
C5:L23C5=LET(n,$B$1, i,SEQUENCE(n-1,,0), k,INT((SEQUENCE(,n-2)+1)/2), s,IF(ISODD(SEQUENCE(,n-2)),1,-1), res,HSTACK(EXPAND(1,$B$1-1,,1),i+2,MOD(i+k*s,n-1)+2), rows,WRAPROWS(TOCOL(res),2), pairs,BYROW(rows,LAMBDA(x,CHOOSECOLS(x,1)&" - "&CHOOSECOLS(x,2))), nPairs,(n-1)*(n/2), randomOrder,INT(SEQUENCE(nPairs,,0)/(n/2))+1+BYROW(SEQUENCE(nPairs),LAMBDA(x,RAND())), orderedPairs,SORTBY(pairs,randomOrder), final,WRAPROWS(orderedPairs,n/2), final)
Dynamic array formulas.
 
Upvote 0
One modification more. The random number generation now depends on the seed, so if you need the same distribution twice or just want to remember the last one, put in the same seed as before and you will get the same pairs distribution:

GolfPairs.xlsx
ABCDEFGHIJKLMNOPQ
1n30(n even)
2Seed16/01/2024
3
4Pairs
5123456789101112131415
6Weeks112 - 2114 - 195 - 2815 - 1816 - 1713 - 2010 - 231 - 24 - 299 - 243 - 3011 - 227 - 266 - 278 - 25
728 - 271 - 316 - 1914 - 216 - 2912 - 239 - 2610 - 255 - 3011 - 2415 - 207 - 284 - 213 - 2217 - 18
839 - 288 - 291 - 416 - 217 - 3011 - 2612 - 256 - 25 - 315 - 2217 - 2018 - 1910 - 2713 - 2414 - 23
9413 - 266 - 410 - 2911 - 2819 - 2015 - 2412 - 2716 - 2318 - 219 - 3017 - 227 - 38 - 214 - 251 - 5
10514 - 2710 - 21 - 618 - 2317 - 2415 - 2616 - 2511 - 3019 - 229 - 313 - 288 - 47 - 520 - 2112 - 29
11612 - 211 - 314 - 2918 - 2516 - 2710 - 49 - 58 - 620 - 2317 - 2613 - 3015 - 2821 - 2219 - 241 - 7
12713 - 318 - 2711 - 514 - 220 - 251 - 816 - 2910 - 69 - 715 - 3022 - 2319 - 2617 - 2812 - 421 - 24
1381 - 920 - 2721 - 2623 - 2410 - 819 - 2817 - 3014 - 418 - 2911 - 712 - 615 - 322 - 2513 - 516 - 2
14921 - 2819 - 3024 - 251 - 1022 - 2718 - 212 - 815 - 523 - 2613 - 716 - 417 - 311 - 914 - 620 - 29
151015 - 718 - 424 - 2717 - 513 - 925 - 2614 - 816 - 622 - 291 - 1120 - 223 - 2821 - 3012 - 1019 - 3
161120 - 414 - 1021 - 316 - 822 - 213 - 1126 - 2723 - 3018 - 61 - 1215 - 917 - 725 - 2824 - 2919 - 5
171222 - 425 - 3016 - 1018 - 819 - 726 - 2921 - 515 - 1114 - 1227 - 2823 - 31 - 1324 - 220 - 617 - 9
181326 - 221 - 723 - 518 - 1028 - 2916 - 1224 - 41 - 1415 - 1325 - 322 - 620 - 819 - 917 - 1127 - 30
191417 - 1318 - 1227 - 320 - 1023 - 729 - 3019 - 1124 - 628 - 21 - 1526 - 425 - 516 - 1421 - 922 - 8
201526 - 630 - 228 - 427 - 521 - 1122 - 1017 - 1518 - 1429 - 324 - 820 - 1219 - 1325 - 71 - 1623 - 9
211625 - 923 - 1127 - 71 - 1729 - 521 - 1319 - 1528 - 620 - 1430 - 42 - 318 - 1624 - 1022 - 1226 - 8
221730 - 621 - 1527 - 92 - 520 - 1619 - 1728 - 826 - 101 - 1829 - 73 - 423 - 1325 - 1122 - 1424 - 12
231824 - 1420 - 1826 - 1225 - 1321 - 1730 - 828 - 1027 - 112 - 729 - 94 - 522 - 163 - 623 - 151 - 19
241930 - 1027 - 135 - 63 - 823 - 174 - 726 - 142 - 928 - 1229 - 1125 - 1521 - 191 - 2022 - 1824 - 16
252028 - 1430 - 1226 - 1627 - 1525 - 1724 - 186 - 73 - 1029 - 134 - 923 - 1922 - 202 - 111 - 215 - 8
26215 - 1029 - 152 - 131 - 2228 - 1630 - 144 - 1125 - 197 - 83 - 1226 - 1823 - 2124 - 206 - 927 - 17
272227 - 195 - 123 - 1426 - 201 - 234 - 1325 - 2130 - 167 - 1024 - 2228 - 1829 - 178 - 92 - 156 - 11
28234 - 158 - 1125 - 2327 - 217 - 125 - 141 - 249 - 1028 - 203 - 1626 - 2230 - 1829 - 196 - 132 - 17
29243 - 1830 - 2010 - 111 - 258 - 139 - 127 - 1429 - 215 - 1628 - 224 - 1726 - 2427 - 232 - 196 - 15
302530 - 2210 - 137 - 1611 - 124 - 1927 - 256 - 179 - 145 - 188 - 1528 - 2429 - 233 - 201 - 262 - 21
31266 - 193 - 227 - 1812 - 135 - 201 - 2730 - 244 - 2128 - 262 - 2329 - 2511 - 1410 - 159 - 168 - 17
322710 - 1729 - 2713 - 148 - 195 - 223 - 2411 - 164 - 239 - 187 - 202 - 2512 - 1530 - 261 - 286 - 21
33287 - 2230 - 289 - 2010 - 195 - 2413 - 168 - 211 - 2912 - 172 - 2711 - 183 - 266 - 234 - 2514 - 15
342915 - 163 - 281 - 306 - 257 - 244 - 2714 - 178 - 239 - 2210 - 215 - 2613 - 182 - 2911 - 2012 - 19
Random order With Seed
Cell Formulas
RangeFormula
C5:Q5C5=SEQUENCE(,B1/2)
B6:B34B6=SEQUENCE(B1-1)
C6:Q34C6=LET(n,$B$1, i,SEQUENCE(n-1,,0), k,INT((SEQUENCE(,n-2)+1)/2), s,IF(ISODD(SEQUENCE(,n-2)),1,-1), res,HSTACK(EXPAND(1,$B$1-1,,1),i+2,MOD(i+k*s,n-1)+2), rows,WRAPROWS(TOCOL(res),2), pairs,BYROW(rows,LAMBDA(x,CHOOSECOLS(x,1)&" - "&CHOOSECOLS(x,2))), nPairs,(n-1)*(n/2), randomNumbers,DROP(REDUCE(B2*(2^31-1)/73051,SEQUENCE(nPairs),LAMBDA(x,y,VSTACK(x,MOD(48271*CHOOSEROWS(x,-1),2^31-1)))),1)/(2^31-1), randomOrder,INT(SEQUENCE(nPairs,,0)/(n/2))+1+randomNumbers, orderedPairs,SORTBY(pairs,randomOrder), final,WRAPROWS(orderedPairs,n/2), final)
Dynamic array formulas.
 
Upvote 0
You are welcome. This was a fun one to solve. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,215,121
Messages
6,123,177
Members
449,093
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top