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
__________
April 2026 March 2026 February 2026 January 2026 December 2025 October 2025 September 2025 August 2025 July 2025 June 2025 May 2025 April 2025 March 2025 October 2024 May 2024 April 2024 March 2024 February 2024 January 2024 December 2023 November 2023 August 2023 May 2023 April 2023 March 2023 March 2021 February 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 April 2019 March 2019 February 2019 January 2019 December 2018 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 January 2006 November 2005 August 2005 July 2005 June 2005 April 2005 March 2005 February 2005 January 2005 December 2004