This project requires someone familiar in math and algorithms
Please fix the following 2 functions that are the reverse of one another please consider that the factorial of 8! = 40320 and 2^16 = 65536 so when 8 non-repeating possibilities are used the 16 bit translation of the order from the array works and when 1 or more numbers from the array is repeated this also needs to be fixed in this algorithm to always return in function 2 numbers between 0 and 7:
Please verify in a loop all possibilities working to fix the following algorithm
func1:
dst_BitString parameter is a string made up of 16 1 s and 0 s that needs to be returned based on the order of numbers in src_Order
src_Order parameter is an array made up of numbers between 0 and 65535 not ordered
func2:
src_BitString parameter is a string made up of 16 1 s and 0 s that represent the order from func1 variable dst_BitString
dst_Order parameter is an array made up of numbers between 0 and 7 that needs to be returned with the order of the numbers from src_Order
int func1(char* dst_BitString, int* src_Order)
{
int n = 0;
for (int i = 0; i < 8; i++)
{
int k = 0;
for (int j = i + 1; j < 8; j++)
{
if (src_Order[i] > src_Order[j])
k++;
}
n *= (8 - i);
n += k;
}
int b = 1 << 15;
for (int i = 0; i < 16; i++)
{
dst_BitString[i] = (b & n) ? '1' : '0';
b >>= 1;
}
dst_BitString[16] = 0;
return n;
}
int func2(int* dst_Order, char* src_BitString)
{
int n = 0;
for (int i = 0; i < 16; i++)
{
n <<= 1;
n += src_BitString[i] == '1' ? 1 : 0;
}
int n8 = 1;
for (int i = 0; i < 8; i++)
{
dst_Order[i] = i;
n8 *= i + 1;
}
int m = n;
for (int i = 0; i < 8; i++)
{
n8 /= (8 - i);
int k = m / n8;
int t = dst_Order[i + k];
// .....i..k.................
for (int j = i + k; j > i; j--)
dst_Order[j] = dst_Order[j - 1];
dst_Order[i] = t;
m -= k * n8;
}
return n;
}
Hello. How are you today.
I have read and understood the project.
I have strong knowledge in Data structures and Algorithms.
And I'm expert in C/++.
I'm interested this project.
I'll fix soon.
I wait for your good reply.
Thanks.