Additional information on the StraightsMatrix Excel File.

Published:

Updated:

Hello everyone,

The other day we posted an Excel file with a simple example of a function we created to find straight combos from a square matrix.

You can get the file here for reference --> https://members.lotterypost.com/jadelottery/StraightsMatrix.xls

Essentially, this is a simple wheel for Daily Pick 3.

We actually use this in our Pick 3 Hot Box program under the ' Fill the Play Combos ' options as ' Straight from the Side ' .

It works by creating straight combos from the left side of the square matrix to the right side.

The general square matrix is the following.

Inputs
A    B    C
D    E    F
G    H    I

The function takes the inputs and runs through the permutations for each column and removes any duplication after creating the playable list.

The playable list is generally the following.

Outputs
A B C
A B F
A B I
A E C
A E F
A E I
A H C
A H F
A H I
D B C
D B F
D B I
D E C
D E F
D E I
D H C
D H F
D H I
G B C
G B F
G B I
G E C
G E F
G E I
G H C
G H F
G H I

By example, if the following are the inputs.

Inputs
2    4    5
5    2    8
9    6    4

Then the outputs are...

Outputs
224
225
228
244
245
248
264
265
268
524
525
528
544
545
548
564
565
568
924
925
928
944
945
948
964
965
968

An example of a case where duplicates are removed.

Inputs
4    9    4
4    0    3
2    5    3

Outputs
203
204
253
254
293
294
403
404
453
454
493
494

Duplicates are created when any two or more numbers are the same; in the same column.

In the above example, because 4 and 4 are in the first column; 3 and 3 are in the last column, it creates duplicates through the permutation process.

The original output would look like the following, color highlighted for the duplication and the non-duplication are Italic.

Outputs
494
493
493
404
403
403
454
453
453
494
493
493
404
403
403
454
453
453
294
293
293
204
203
203
254
253
253

The program code working behind the scenes is the following.

__________

  Dim arry() As Integer

  Public Function StraightsMatrix(ByVal theRange As Range) As String
    Randomize(Timer)
    ReDim arry(27) As Integer
    Dim tmp As String
    tmp = ""
    If (theRange.Rows.Count = 3) And (theRange.Columns.Count = 3) Then
      For a = 1 To 3
        For b = 1 To 3
          For c = 1 To 3
            arry(1 + 1 * (c - 1) + 3 * (b - 1) + 9 * (a - 1)) = 100 * Val(theRange.Cells(a, 1)) + 10 * Val(theRange.Cells(b, 2)) + 1 * Val(theRange.Cells(c, 3))
          Next
        Next
      Next
      QuickSort(1, 27)
      For r = 1 To 26
        If arry(r) <> arry(r + 1) Then
          tmp = tmp & " " & Format(arry(r), "000")
        End If
        If r = 26 Then
          tmp = tmp & " " & Format(arry(r + 1), "000")
        End If
      Next
      StraightsMatrix = tmp
    Else
      StraightsMatrix = ""
    End If
  End Function

  Sub QuickSort(ByVal Low As Long, ByVal High As Long)
    Dim RandIndex, i, j As Integer
    Dim p As Integer
    If Low < High Then
      If High - Low = 1 Then
        If arry(Low) > arry(High) Then
          SwapArrayElements(Low, High)
        End If
      Else
        RandIndex = RandInt(Low, High)
        SwapArrayElements(High, RandIndex)
        p = arry(High)
        Do
          i = Low : j = High
          Do While (i < j) And (arry(i) <= p)
            i = i + 1
          Loop
          Do While (j > i) And (arry(j) >= p)
            j = j - 1
          Loop
          If i < j Then
            SwapArrayElements(i, j)
          End If
        Loop While i < j
        SwapArrayElements(i, High)
        If (i - Low) < (High - i) Then
          QuickSort(Low, i - 1)
          QuickSort(i + 1, High)
        Else
          QuickSort(i + 1, High)
          QuickSort(Low, i - 1)
        End If
      End If
    End If
  End Sub

  Sub SwapArrayElements(ByVal a, ByVal b)
    Dim hold As Integer
    hold = arry(a)
    arry(a) = arry(b)
    arry(b) = hold
  End Sub

  Function RandInt(ByVal Lower, ByVal Upper) As Integer
    RandInt = Int(Rnd * (Upper - Lower + 1)) + Lower
  End Function

__________

Entry #2,485

Comments

This Blog entry currently has no comments.

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register