Created
November 9, 2021 12:00
-
-
Save avipars/90ac17fcfdea410fd8927247f706d79f to your computer and use it in GitHub Desktop.
I needed a quick solution to check permutations and substitutions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace std; | |
bool isEq = false; | |
int equ = 0; | |
int isOne(bool number) | |
{ | |
if (number) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} | |
bool isOne(int number) | |
{ | |
if (number >= 1) | |
{ | |
return true; | |
} | |
else | |
{ | |
return false; | |
} | |
} | |
//permutations | |
void permutate(int a, int b, int c, int d) | |
{ | |
cout << " " << a << " " << b << " " << c << " " << d << endl; | |
int cnot, dnot; | |
cnot = (c == 0) ? cnot = 1 : cnot = 0; | |
dnot = (d == 0) ? dnot = 1 : dnot = 0; | |
int totleft = isOne(a * b) + isOne(a * cnot) + isOne(c * d); | |
bool toLeft = isOne(totleft); | |
cout << "Total Left: " << toLeft << endl; | |
int totRight = isOne(cnot * dnot); | |
bool toRight = isOne(totRight); | |
cout << "Total Right: " << toRight << endl; | |
if (toLeft == toRight) { | |
cout << "is equivelent " << endl; | |
isEq = true; | |
equ++; | |
} | |
else { | |
cout << "is not equivelent " << endl; | |
isEq = false; | |
} | |
return; | |
} | |
int main() | |
{ | |
permutate(1, 0, 0, 0); | |
permutate(0, 1, 0, 0); | |
permutate(0, 0, 1, 0); | |
permutate(0, 0, 0, 1); | |
permutate(1, 1, 0, 0); | |
permutate(0, 1, 1, 0); | |
permutate(0, 0, 1, 1); | |
permutate(1, 0, 1, 0); | |
permutate(1, 0, 0, 1); | |
permutate(0, 1, 1, 0); | |
permutate(0, 1, 0, 1); | |
permutate(1, 0, 1, 1); | |
permutate(1, 1, 0, 1); | |
permutate(1, 1, 1, 0); | |
permutate(1, 1, 1, 1); | |
permutate(0, 0, 0, 0); | |
cout << "old total equiv: " << equ << endl; | |
equ = 0; | |
cout << "NEW" << endl; | |
permutate(0, 0, 0, 0); | |
permutate(0, 0, 0, 1); | |
permutate(0, 0, 1, 0); | |
permutate(0, 0, 1, 1); | |
permutate(0, 1, 0, 0); | |
permutate(0, 1, 0, 1); | |
permutate(0, 1, 1, 0); | |
permutate(0, 1, 1, 1); | |
permutate(1, 0, 0, 0); | |
permutate(1, 0, 0, 1); | |
permutate(1, 0, 1, 0); | |
permutate(1, 0, 1, 1); | |
permutate(1, 1, 0, 0); | |
permutate(1, 1, 0, 1); | |
permutate(1, 1, 1, 0); | |
permutate(1, 1, 1, 1); | |
cout << "new total equiv: " << equ << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using namespace std;
bool isEq = false;
int equ = 0;
int isOne(bool number)
{
if (number)
{
return 1;
}
else
{
return 0;
}
}
bool isOne(int number)
{
if (number >= 1)
{
return true;
}
else
{
return false;
}
}
//permutations
void permutate(int a, int b, int c, int d)
{
cout << " " << a << " " << b << " " << c << " " << d << endl;
int cnot, dnot;
cnot = (c == 0) ? cnot = 1 : cnot = 0;
dnot = (d == 0) ? dnot = 1 : dnot = 0;
}
//permutations
void newPermute(int a, int b)
{
cout << "newPermute " << a << " " << b << endl;
int anot, dnot;
anot = (a == 0) ? anot = 1 : anot = 0;
}
//permutations
void thirdPermute(int a, int b, int c)
{
cout << "3perm " << a << " " << b << " " << c << endl;
}
int main()
{
/* permutate(1, 0, 0, 0);
permutate(0, 1, 0, 0);
permutate(0, 0, 1, 0);
permutate(0, 0, 0, 1);
permutate(1, 1, 0, 0);
permutate(0, 1, 1, 0);
permutate(0, 0, 1, 1);
permutate(1, 0, 1, 0);
permutate(1, 0, 0, 1);
permutate(0, 1, 1, 0);
permutate(0, 1, 0, 1);
permutate(1, 0, 1, 1);
permutate(1, 1, 0, 1);
permutate(1, 1, 1, 0);
permutate(1, 1, 1, 1);
permutate(0, 0, 0, 0);*/
//cout << "old total equiv: " << equ << endl;
//equ = 0;
/* permutate(0, 0, 0, 0);
permutate(0, 0, 0, 1);
permutate(0, 0, 1, 0);
permutate(0, 0, 1, 1);
permutate(0, 1, 0, 0);
permutate(0, 1, 0, 1);
permutate(0, 1, 1, 0);
permutate(0, 1, 1, 1);
permutate(1, 0, 0, 0);
permutate(1, 0, 0, 1);
permutate(1, 0, 1, 0);
permutate(1, 0, 1, 1);
permutate(1, 1, 0, 0);
permutate(1, 1, 0, 1);
permutate(1, 1, 1, 0);
permutate(1, 1, 1, 1);*/
}