The 4-digit lock from 0-9 (which is 10 possibilities in each position, not 9) is totally different. It would have 10000 possible combinations. It is different in two ways. Firstly, numbers can repeat, e.g., the combo could be 5555. Secondly, the order matters, e.g., 1234 and 4321 are different.
But in powerball, just considering the white balls, 1 2 3 4 5 and 5 4 3 2 1 are exactly the same. There are 5! = 120 ways to permute 5 numbers. Therefore you need to divide by 120 to discount them.
BTW, there is, of course, no way to "win" the powerball. If a particular sequence has come up before, it is just as likely as any other sequence to come up again, i.e., any given sequence is very unlikely.
You could print all possible powerball drawings like this, but it will produce well over 5 gigabytes of output. You can test it with smaller values for WhiteMax and PowMax. 8 and 2 are nice small values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
const int WhiteMax = 69;
const int PowMax = 26;
void print(int a, int b, int c, int d, int e, int p) {
std::cout << a << ' ' << b << ' ' << c << ' '
<< d << ' ' << e << ' ' << p << '\n';
}
int main() {
for (int a = 1; a <= WhiteMax-4; a++)
for (int b = a + 1; b <= WhiteMax-3; b++)
for (int c = b + 1; c <= WhiteMax-2; c++)
for (int d = c + 1; d <= WhiteMax-1; d++)
for (int e = d + 1; e <= WhiteMax; e++)
for (int p = 1; p <= PowMax; p++)
print(a,b,c,d,e,p);
}
|