generate all 7-letter formations, maximum 3 letters repeated.

piter

Active Member
Joined
Jul 22, 2011
Messages
316
Office Version
  1. 2016
Platform
  1. Windows
generate all 7-letter formations, maximum 3 letters repeated.
ex = aaabcde ... bbbcccd, etc.
we have 10 letters = abcdefghij to conbine the formations with 7 letters
please!
 
Last lottery draw was = 07 11 12 17 25 29 30, logo
then it would be in the lines = abbbccc / in the abdeggi columns (which lack to make these patterns)
each draw has the two patterns x lines carteziano type
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
After looking at your post 6 again, I think I detected your pattern. It appears to count up like an odometer, with the added provision that each digit must be greater than or equal to the digit on its left. Using that logic, I duplicated your list from post 6. Using 4 letters, the list grew to 120 items.

To try this code, open a new workbook. Press Alt-F11 to open the VBA editor. From the menu, click Insert > Module. Paste the following code into the window that opens:

Rich (BB code):
Public MyDict

Sub GetCombs()

    Set MyDict = CreateObject("Scripting.Dictionary")
    Call Recur("abcdefghij", 0, "")
    
    Range("A1").Resize(MyDict.Count) = WorksheetFunction.Transpose(MyDict.keys)
    
End Sub

Sub Recur(chars, depth, sofar)
Dim i As Long
    
    If depth = 7 Then
        MyDict.Add sofar, 1
        Exit Sub
    End If
    
    For i = InStr(chars, Right(sofar, 1)) To Len(chars)
        Call Recur(chars, depth + 1, sofar & Mid(chars, i, 1))
    Next i

End Sub
Place the cursor in the GetCombs routine and press F5. It should generate the list in the workbook in column A. There are 11440 items.

Note that this routine requires each letter in the list to be different.


Note: I just saw your latest post. I'm still not clear on what you're looking for. But if you're looking for something to help with lottery picks, be aware that this kind of analysis usually doesn't help.
 
Upvote 0
ok ERIC! almost there, but inside the trainings can not have letters repeated more than 3 times
the maximum repetition limit is 3 letters 10 possible letters
can not have ijjjjjj = exclude by passing the limit of 3 letters
aabbjjj = yes because it has a maximum of three letters, it is logical if in each colua I have 3 numbers I can not have 4 repetitions understand!
 
Upvote 0
Rich (BB code):
Public MyDict

Sub GetCombs()

    Set MyDict = CreateObject("Scripting.Dictionary")
    Call Recur("abcdefghij", 0, "")
    
    Range("A1").Resize(MyDict.Count) = WorksheetFunction.Transpose(MyDict.keys)
    
End Sub

Sub Recur(chars, depth, sofar)
Dim i As Long
    
    If depth = 7 Then
        MyDict.Add sofar, 1
        Exit Sub
    End If
    
    For i = InStr(chars, Right(sofar, 1)) To Len(chars)
        If Right(sofar, 3) <> String(3, Mid(chars, i, 1)) Then
            Call Recur(chars, depth + 1, sofar & Mid(chars, i, 1))
        End If
    Next i

End Sub
 
  • Like
Reactions: shg
Upvote 0
Eric, re your code, a max of three repeats of each symbol is allowed.

There are 8 partitions of 7 with no number greater than 3: 3+3+1, 3+2+2, 3+2+1+1, ... 1+1+1+1+1+1+1

For the first one, there are 10 choose 2 = 45 ways to choose the 'three-fers', and 8 choose 1 = 8 ways to choose the 'one-fer', so 360 ways total.

Similarly,

[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][td="bgcolor:#C0C0C0"]
E​
[/td][td="bgcolor:#C0C0C0"]
F​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td]
3​
[/td][td]
2​
[/td][td]
1​
[/td][td="bgcolor:#F3F3F3"]
Check
[/td][td="bgcolor:#F3F3F3"]
Ways
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]
2​
[/td][td]
0​
[/td][td]
1​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
360​
[/td][td]E2: =COMBIN(10, A2) * COMBIN(10 - A2, B2) * COMBIN(10 - SUM(A2:B2), C2)[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]
1​
[/td][td]
2​
[/td][td]
0​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
360​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]
1​
[/td][td]
1​
[/td][td]
2​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
2520​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]
1​
[/td][td]
0​
[/td][td]
4​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
1260​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
6​
[/td][td]
0​
[/td][td]
3​
[/td][td]
1​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
840​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
7​
[/td][td]
0​
[/td][td]
2​
[/td][td]
3​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
2520​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
8​
[/td][td]
0​
[/td][td]
1​
[/td][td]
5​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
1260​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
9​
[/td][td]
0​
[/td][td]
0​
[/td][td]
7​
[/td][td="bgcolor:#E5E5E5"]
7​
[/td][td="bgcolor:#E5E5E5"]
120​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
10​
[/td][td][/td][td][/td][td][/td][td="bgcolor:#F3F3F3"]
Total
[/td][td="bgcolor:#E5E5E5"]
9240​
[/td][td][/td][/tr]
[/table]


That gives 9240 combinations.

EDIT: Reckon I should have run your later code :)
 
Last edited:
Upvote 0
Very nice analysis, shg. My latest macro indeed returns 9240 combinations, so that's a nice check.
 
  • Like
Reactions: shg
Upvote 0
ok perfect, very good job, ERIC AND SHG, congratulations,
Okay, thank you for resolving the issue.
 
Upvote 0
Decade 0 01-09 A
Decade 1 10-19 B
Decade 2 20-29 C
Decade 3 30-39 D
Decade 4 40-49 E

So, for example, the last UK lotto draw was 2-3-5 -15-22-29 which would translate into AAABCC. I split these up into front and back triples, e.g. AAA, BCC.

I just noticed that there are several patterns that have NEVER come out in the 20 year history of the UK Lotto. Not to say they won't ever appear, but these combos are seriouslyunlikely!

For the Front three, combos AEE, CCE, BEE, DEE, CEE or EEE have not appeared to date. So, if your system spits out a combo that has 40's in the front three of the combo, delete it. Most sum filters would automatically delete these combos anyway.

For the Back three, ABB, ADE, AAC, AAA, ABC, AAD and AAE have not appeared in the first 20 years of draws. I am a bit surprised to see ADE on the list as I wouldn't be surprised to see a combo with 4 single digits, a thirty and a forty -- but it hasn't happened yet.

On the other hand, 59% of the first three follow patterns ABC, AAB, ABB, BBC and AAAlisted in order of most appearances. For the back end, the top triples are DEE, DDE, CDE, EEE and CDD accounting for 67% of all draws.
 
Upvote 0
objetivo filter 3 letters
For the front end triple, only 16 combinations make up 95% of the winning combinations. These are (listed by number of hits):
AAB, ABB, ABC, AAC, AAA, BBC, ACC, BCC, BBB, ACD, BCD, ABD, AAD, CCC, CCD and BBD

And, for the back-end triple only 15 combinations are used 95% of the time:
DEE, DDE, CDE, EEE, CDD, CEE, CCD, CCE, DDD, BCE, BDE, BCD, BDD, CCC and BBD.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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