I am a student of number truth and I have taken on a mathematical problem to further disprove if numbers are truly random and can be predicted using high order mathematical truths this is why I have chosen the State-run lottery as my random number generator.
I have a dilemma one of the things I need to further my work is a list. I have been out of programming in C++ for 25 years. When I was into it I was very proficient in C++ 11. I have taken steps to get up to speed with C++ 17 but this is not my problem.
I need to generate and print to file a list of all possible 5 digit numbers in ascending order using the numbers 1 through 70.
Example: 1,2,3,4,5, would be the first and smallest number in the list and the Largest number would be 70,69,68,67,66, no number can be used in more than one place of the 5 digit number at a time.
Number possible.
Example:
1,2,3,4,5,
1,2,3,4,6,
1,2,3,4,7,
1,2,3,4,8,
1,2,3,4,9,
Missing numbers between: 1,2,3,5,0, - 1,2,3,5,3, Total of 4 numbers not possible.
1,2,3,5,4,
Missing number: 1,2,3,5,5, not possible.
1,2,3,5,6,
1,2,3,5,7,
1,2,3,5,8,
1,2,3,5,9,
Missing numbers between: 1,2,3,6,0, - 1,2,3,6,3, Total of 4 numbers not possible.
1,2,3,6,4,
1,2,3,6,5,
Missing number: 1,2,3,6,6, not possible.
1,2,3,6,7,
1,2,3,6,8,
1,2,3,6,9,
You get the idea.
Dynamically optimizing is not necessary at this time.
Any help with the Algorithm and in my endeavor would be appreciated.
#include <iostream>
#include <set>
#include <vector>
usingnamespace std;
void range( int a, int b, int n, set<int> &S, vector<int> &V )
{
if ( n )
{
for ( int i = a; i <= b; i++ )
{
if ( S.insert( i ).second )
{
V.push_back( i );
range( a, b, n - 1, S, V );
S.erase( i );
V.pop_back();
}
}
}
else
{
for ( int e : V ) cout << e << " ";
cout << '\n';
}
}
int main()
{
int a = 1, b = 5, n = 3; // For demo
// int a = 1, b = 70, n = 5; // The lottery
set<int> S;
vector<int> V;
range( a, b, n, S, V );
}
after you generate this, consider dumping it into a file you can read next time, so you only have to generate it the one time. Then you don't need any kind of high performance generation algorithm or to spend a lot of time on this part. there are only 12.x million if the order of the numbers is not important. If you need the order too, its much, much more.