Esempio n. 1
0
void genPerms(int perms[4*3*2]){
    int i, size = 1;
    int currPerm = perms[0];

    for (i = 1; i < 4*3*2; i++){
        currPerm = nextPerm(currPerm);
        if (perms[size-1] == currPerm) return; 
        if (primes[currPerm]){
            perms[size] = currPerm;
            size++;
        }
    }
}
Esempio n. 2
0
int main() {

    // Test with this initial permutation.
    int perm[] = {1,1,2,2};

    // Keep on going until the last permutation.
    int cont = 1;
    while (cont) {
        printPerm(perm, 4);
        cont = nextPerm(perm, 4);
    }

    return 0;
}
Esempio n. 3
0
int main() {

    // Test with this initial permutation.    
    int perm[] = {1,2,3,4,5};
    
    // We know there are exactly 120 of these...
    int i = 0;
    for (i=0; i<120; i++) {
        printPerm(perm, 5);
        nextPerm(perm, 5);
    }
    
    system("PAUSE");
    return 0;
}
Esempio n. 4
0
static void getAlgoString(char *str, int seq)
{
	uint8_t algoList[HASH_FUNC_COUNT];
	char *sptr;

	initPerm(algoList, HASH_FUNC_COUNT);

	for (int k = 0; k < seq; k++) {
		nextPerm(algoList, HASH_FUNC_COUNT);
	}

	sptr = str;
	for (int j = 0; j < HASH_FUNC_COUNT; j++) {
		if (algoList[j] >= 10)
			sprintf(sptr, "%c", 'A' + (algoList[j] - 10));
		else
			sprintf(sptr, "%u", (uint32_t) algoList[j]);
		sptr++;
	}
	*sptr = '\0';
}