[AccessD] miracle required apparently

jack drawbridge jackandpat.d at gmail.com
Tue Oct 17 18:43:05 CDT 2023


Steve,
Just some fiddling with numbers for consideration. If  you have 8 players
and two players are required to play a "game". Then, the number of ways of
combining 8 things taking 2 at a time would be 'nCr= N!/r!*(n-r)!
So 8C2 = 8!/(2!*(8-2)!) =28
If you have 4 Games and 4 slots, then you have 16 selections (player  vs
player). Since there are 28 combinations and you are using only 16, it
would seem that not every player would play every other player. However, it
would seem that, if you take any 16 combinations, you will have met your
challenge.

Here are some vba routines I used.
[code]' ----------------------------------------------------------------
' Procedure Name: fact
' Purpose: To evaluate Factorial N (Factorial)
' Procedure Kind: Function
' Procedure Access: Public
' Parameter n (Long): the number to "factorialize"
' Return Type: Long
' Author: Jack
' Date: 17-Oct-23
' ----------------------------------------------------------------
Function fact(n As Long) As Long
    Dim I As Long, f As Long
    f = 1
    For I = 1 To n
        f = f * I
    Next I
    fact = f
End Function[/code]
?fact(4)
 24

Combinations of 8 things taken 2 at a time
[code]' ----------------------------------------------------------------
' Procedure Name: combNtakenRataTime
' Purpose: number of combinations of 8 things taken 2 at a time
' Procedure Kind: Function
' Procedure Access: Public
' Parameter n (Long): the number of things for selecting
' Parameter r (Long): the number of things selected in a group
' Return Type: Long
' Author: Jack
' Date: 17-Oct-23
' ----------------------------------------------------------------
Function combNtakenRataTime(n As Long, r As Long) As Long
'number of combinations of 8 things taken 2 at a time
'nCr= N!/r!*(n-r)!
combNtakenRataTime = fact(n) / (fact(r) * fact(n - r))
End Function[/code]
?combNtakenRataTime(8,2)
 28



Display Combinations of 8 things taken 2 at a time
[code]' ----------------------------------------------------------------
' Procedure Name: uniqPairs
' Purpose: To identify the (unique pairs)Combinations  from 8 Players taken
2 at a time
' Procedure Kind: Sub
' Procedure Access: Public
' Author: Jack
' Date: 17-Oct-23
' ----------------------------------------------------------------
Sub uniqPairs()
    Dim P As String: P = "ABCDEFGH"
    Dim I As Integer, X As Integer, cnt As Integer
    For I = 1 To Len(P)
        For X = I + 1 To Len(P)
            Debug.Print cnt; Mid(P, I, 1) & Mid(P, X, 1)
            cnt = cnt + 1
        Next X
    Next I
End Sub[/code]

The 28 combinations of 8c2

0 AB
 1 AC
 2 AD
 3 AE
 4 AF
 5 AG
 6 AH
 7 BC
 8 BD
 9 BE
 10 BF
 11 BG
 12 BH
 13 CD
 14 CE
 15 CF
 16 CG
 17 CH
 18 DE
 19 DF
 20 DG
 21 DH
 22 EF
 23 EG
 24 EH
 25 FG
 26 FH
 27 GH

Note: I am NOT a mathematician, but found your challenge interesting.
Perhaps a math person can confirm or refute the above.

Best of luck with your project.

Jack

On Mon, Oct 16, 2023 at 9:22 PM Steve Schapel <
steve at datamanagementsolutions.biz> wrote:

> Hi all
>
> I'm trying to do something that I initially thought would be reasonably
> easy.  But alas, so far success has eluded me.  Any insights accepted
> with much gratitude!
>
> The goal:  Assign a number of Participants to a number of Activities
> over a number of Sessions.
>
> Very simple example:
>      4 Sessions
>      4 Activities
>      8 Participants (therefore 2 per Activity)
>
> To illustrate:
> Let's say the sessions are 9am, 10am, 11am, 12pm.
> Let's sat the activities are chess, tai chi, bowls, diving
> Let's say the participants are A, B, C, D, E, F, G, H
>
> The stipulation is that each participant should do each activity one
> time.
>
> By trial and error brute force, I know that there is at least one
> solution, namely:
>
>                       chess       tai chi       bowls        diving
>    9am           A & E        C & F        D & G        B & H
> 10am           C & G       A & H       B & E         D & F
> 11am           D & H      B & G        A & F         C & E
> 12pm           B & F       D & E        C & H        A & G
>
> HOWEVER, I have tried multiple angles of looping through nested (and
> sometimes randomised) recordsets based on the core data elements
> (sessions, activities, and participants), to write the assignments to
> the available slots in a schedule table, and to my shock (and horror) we
> always reach the point in the procedure where it gets stuck, due to
> trying to assign a participant to two activities in the same session,
> but with no valid alternative slot available.
>
> There is no problem if the model calls for the super simple option of
> only one participant for each activity.  But otherwise, no dice, so far.
>
> There MUST be a way to make this work?  Surely?
>
> Thanks a lot.
>
> Regards
> Steve
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list