Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6431 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

[color:blue]Greetings

I have exhausted myself searching on Google. This topic has been regurgitated many times but I cannot seem to find the solution that I am looking for.

Forgive me - I am an FM newbie who is fascinated by stats and before I can get to the calculations that I want to perform, I need to calculate every single possible combination of the 49/6 lotto. I know that there are 13,983,816 combo's... I just want to create a database with every single combo.

Please note that I am quite familar with combinations, permutations and the formulae associated with these functions. All sites appear to focus primarily on how many possible combinations of 6 balls drawn from 49 there are. As mentioned above, what I want to do is calculate every single combination. I would thus end up with 13,983,816 records each with 6 numbers.

So - yup - being new at this I am unsure as to whether FM can do this. If FM can do this, it would be most appreciated if someone could guide me as to how to get this right!

Posted (edited)

Since you want a record for each, this will necessarily require a script. You might as well generate the numbers at the same time. I'd suggest a basic set of nested loops with variables to act as loop control and the values of each selection (ball). Something like:

Enter Browse Mode []

Set Variable [ $ball1 ; 1 ]

Loop

Set Variable [ $ball2 ; 1 ]

Loop

Set Variable [ $ball3 ; 1 ]

Loop

New Record/Request

Set Field [ ball1 ; $ball1 ]

Set Field [ ball2 ; $ball2 ]

Set Field [ ball3 ; $ball3 ]

Set Variable [ $ball3 ; $ball3 + 1 ]

Exit Loop If [ $ball3 > 49 ]

End Loop

Set Variable [ $ball2 ; $ball2 + 1 ]

Exit Loop If [ $ball2 > 49 ]

End Loop

Set Variable [ $ball1 ; $ball1 + 1 ]

Exit Loop If [ $ball1 > 49 ]

End Loop

That's a rough algorithm for 3 balls, but the same idea should work for six. I'd suggest trying it on a smaller set like this before attempting to generate 13,983,816 records.

Edited by Guest
Posted

Thanks for the reply...

Like I said - am a real FM newbie... So with reference to your answer, how would you approach the problem if I didn't need a record for each?

('Cus now I see that my logic was faulty: creating 13,983,816 records is slightly insane!)

Posted

I don't think there's a better place to hold 13,983,816 values other than individual records. Especially if you intend to do something with them, beside staring at them.

But it does sound slightly insane. I don't know what calculations you want to perform, but I'd think a sample of the population should be quite sufficient for testing just about anything that comes to mind.

Posted

Good question. Wish I knew the exact answer. It's still a work in progress.

You are gonna think I'm a complete nutter when I say this but: I keep seeing patterns in my head of how to actually predict the lotto. It all boils down to the basics of probability. The reason that I need all possible combinations is that I want to be able to search the database (of all possible combos) and flag all those combos that have been pulled. Yes - I get that past draws have no effect on future draws but it's the patterns that I am trying to identify. . .

While it all might sound far-fetched, it provides a challenge and I'm always game for some mental exercise. . . Plus I get to explore the functions of FM whic his another one of my new-found hobbies...

Again - thanks for the assistance...

Does the above provide any further insight which might prompt you in another solution?

Posted

Greetings

Thank you for your response! I can't believe how helpful people are here! I keep thinking it will take days to get a response and that is certainly not the case!

LOL

Posted

You are gonna think I'm a complete nutter when I say this but: I keep seeing patterns in my head of how to actually predict the lotto.

I'm afraid the first part is a rather safe prediction. Because, as you say:

It all boils down to the basics of probability.

But if you need to convince yourself, go ahead.

I want to be able to search the database (of all possible combos) and flag all those combos that have been pulled.

Why don't you just enter past results, and see how many of each you have? The rest of the combinations are not really information.

In any case, generating all the possible combinations is not difficult, just tiresome. You could use a looping method, as suggested by Ender, or you could simply create the 13,983,816 records with consecutive serial numbers, and populate the 6 ball fields by calculation, using Mod() and Div(). After all, a particular combination of 6 ball values is just another (unique) name for the record's serial number - but now I am regressing back to what I said in the beginning...

Posted

Why don't you just enter past results, and see how many of each you have? The rest of the combinations are not really information.

Well - I have imported all records already. Am still learning FM and have got to the point where I can calculate the frequency of each number from 1 to 49. I must now work out how to perform a search for multiple fields (i.e N1 to N6). Here's a question: is it possible to write a script that identifies all records (draws) that have 3 matches?

or you could simply create the 13,983,816 records with consecutive serial numbers, and populate the 6 ball fields by calculation, using Mod() and Div().

Are you willing to elaborate on the part about populating using Mod() and Div()? Going to do some research into that now... So I understand if this is basic and not worth an explanation, just say the word!

...but now I am regressing back to what I said in the beginning...

Me thinks I am to laugh at that? :o

Posted

I wonder if there's a problem with my suggested algorithm. If the order of the balls matters, then I think it's fine, but if you're talking about combinations the order shouldn't matter, and the duplicates would not be counted (hey, you're the statistician!) If you think about those balls being interchangeable, my looping algorithm create duplicate combinations.

Hmm, I think that'd be 13,841,287,201 (49^6) records, right?

Posted

You're the FM expert... not me... but yes - with the lotto, the order doesn't matter. If the order did matter it would be a permutation (not a combination) and in this case, one would end up with 10,068,347,520 records... ouch!

Calculation for the above would be 49*48*47*46*45*44. Because it doesn't matter what order the balls are drawn, we simply divide the above result by 1*2*3*4*5*6 (720) and you get the 13,983,816 records we were talking about previously!

Posted (edited)

The population by calculation is not too difficult, I think, but not exactly basic either. I would try to adapt the Round Robin algorithm from 2 teams to 6 balls. For convenience, the results should be sorted - this can be done rather simply by the FilterValues() function.

EDIT:

I did a sketchy search on this, and it appears to be considerable more difficult than I thought at first, when dealing with 6 variables. The best method I can think of right now is something like this:

Initialize a set of 6 variables with these values: 1 ; 2 ; 3 ; 4 ; 5 ; 6

Increase the value of the variable #6 by 1, until it reaches 49. Then increase the value of variable #5 by 1, and reset variable #6 to variable #5 + 1.

Repeat this until variable #5 reaches 48. Then increase the value of variable #4 by 1, and reset variable #5 to variable #4 + 1 and variable #6 to variable #5 + 1.

This continues, until the 6 variables have reached the values: 44 ; 45 ; 46 ; 47 ; 48 ; 49

Edited by Guest

This topic is 6431 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.