Juggling Sequence Permutation Test

This is a basic program that uses the permutation test to display all possible juggling sequences of a certain period and with a certain number of balls. The program can be easily modified to ask the user for the period and number of balls required. Right now, it is hard coded in. The number of balls is 2 and the period is 4. Thus the sum of all of the beats in the sequence must be 8 and the average 2.

I worked on this in class, so please excuse the messy coding. I did not think that I would be showing the source code to anyone else.

 

//Justin Yang
//9-17-2013
//2:02 PM

#include
#include

using namespace std;

int main()
{
int x = 0;
int y = 0;
int z = 0;
int limit_one = 0;
int limit_two = 0;
int limit_three = 0;
int limit_four = 0;
int a_one[2];
int a_two[2];
int a_three[2];
int a_four[2];

int a, b, c, d, n;

cout << "Please input a, b, c, d: "; cin >> a >> b >> c >> d;

cout << "a: " << endl;
n = 0;
int lol = 0;
for (int i = 0; i < 10; i++)
{
if (((n + 0) % 4) == a){
cout << "\t" << n << endl;
a_one[lol] = n;
lol++;

limit_one++;
}
n++;
}

cout << "b: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 1) % 4 == b){
cout << "\t" << n << endl;
a_two[lol] = n;
lol++;
limit_two++;
}
n++;
}
cout << "c: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 2) % 4 == c){
cout << "\t" << n << endl;
a_three[lol] = n;
lol++;
limit_three++;
}
n++;
}
cout << "d: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 3) % 4 == d){
cout << "\t" << n << endl;
a_four[lol] = n;
lol++;
limit_four++;
}
n++;
}

/** for (int i = 0; i < limit_one; i++) cin >> a_one[i];

for (int i = 0; i < limit_two; i++) cin >> a_two[i];

for (int i = 0; i < limit_three; i++) cin >> a_three[i];

for (int i = 0; i < limit_four; i++) cin >> a_four[i];
**/

for (x; x < 3; x++)
{
// int n = a_one[x];
// cout << "A_One: " << a_one[x] << endl;
for (int y = 0; y < 3; y++)
{
// n += a_two[y];
// cout << "A_Two: " << a_two[y] << endl;
for (int z = 0; z < 3; z++)
{
// n += a_three[z];
// cout << "A_Three: " << a_three[z] << endl;
for (int i = 0; i < 3; i++)
{

// cout << "A_Four: " << a_four[i] << endl;
if ((a_one[x] + a_two[y] + a_three[z] + a_four[i]) == 8)
cout << a_one[x] << " " << a_two[y] << " " << a_three[z] << " " << a_four[i] << endl;
}
}
}
}

cout << "This is before System Pause." << endl;
system("PAUSE");
return 0;

}

Leave a Reply

Your email address will not be published. Required fields are marked *