String Factorial??
-
I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.
-
I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.
Kinda cheesy but here's one way:
CStringArray arr;
CString str;for (char l1 = 'A'; l1 <= 'E'; l1++)
{
str = l1;
arr.Add(str);
}for (l1 = 'A'; l1 <= 'E'; l1++)
{
for (char l2 = 'A'; l2 <= 'E'; l2++)
{
str = l1 + l2;
arr.Add(str);
}
}for (l1 = 'A'; l1 <= 'E'; l1++)
{
for (char l2 = 'A'; l2 <= 'E'; l2++)
{
for (char l3 = 'A'; l3 <= 'E'; l3++)
{
str = l1 + l2 + l3;
arr.Add(str);
}
}
}for (l1 = 'A'; l1 <= 'E'; l1++)
{
for (char l2 = 'A'; l2 <= 'E'; l2++)
{
for (char l3 = 'A'; l3 <= 'E'; l3++)
{
for (char l4 = 'A'; l4 <= 'E'; l4++)
{
str = l1 + l2 + l3 + l4;
arr.Add(str);
}
}
}
}for (l1 = 'A'; l1 <= 'E'; l1++)
{
for (char l2 = 'A'; l2 <= 'E'; l2++)
{
for (char l3 = 'A'; l3 <= 'E'; l3++)
{
for (char l4 = 'A'; l4 <= 'E'; l4++)
{
for (char l5 = 'A'; l5 <= 'E'; l5++)
{
str = l1 + l2 + l3 + l4 + l5;
arr.Add(str);
}
}
}
}
}I believe that yields 3,905 (51 + 52 + 53 + 54 + 55) combinations.
-
I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.
may you describe it a bit more? but... if you create a "normal" hashkey which is suitable for the hashspace, and then transform it to ASCII? LOWELL = 76 79 87 69 76 76 -> S = 7679 + 8769 + 7676 = 24124 your hashspace is 19937 (should be prime) 24124 % 19937 = 4187 and now put it to ASCII 41 and 87 :confused: