Hey folks,
I am trying to normalize a view on a given output. This is how it works, I need to print several characters but the maximum chars i can print have to be 40 per line.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa...till 40
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbb
The algorithm works as follows:
I have to find the highest number on the array (letters[]) then if this number is higher than 40 then I have to scale it. scaleFactor = (40 / max_count) Then multiply each number on letters[] by the scaling factor so that when I print the letters they come up in a nice scale. This works flawlessly, however, There are some letters that do not print because there aren't many occurrences for them.
I would like to at least print these letters once to indicate that they are there.Further explanation:
scaleFactor = 0.002952
So if I have 8000 A's it normalizes to 23.16 which is fine
But if I have only 10 B's it normalized to 0.02952 so no B's get printed.
max_count = getMaxCount(letters);
if (max_count > 40) {
float factor = max_count; // Convert to float
scaleFactor = (40 / factor);
for(int i = 0; i < 26; i++) {
letters[i] = (letters[i] * scaleFactor);
}
}