int kod(int *cnts, int i, int *j, int *k, int nsyms) { int r; if(*k > nsyms || i > *j && cnts[*j] < cnts[*k]) { r = cnts[*j]; cnts[(*j)++] = i; } else r = cnts[(*k)++]; return r; }
int huff(int *cnts, int nsyms) { int i = 0, j = 0, k = 0; for(i=0;i<nsyms-1;i++) cnts[i] = kod(cnts, i, &j, &k, nsyms) + kod(cnts, i, &j, &k, nsyms); cnts[i] = 2; j = i-1; k = j; while(k) { while(j > 0 && cnts[j-1] >= k) j--; cnts[i--] -= k - j; cnts[i] = (k - j)*2; k = j; } return nsyms - i; }
Thank you new admin, now I can browse /prog/ again. I love you. What's with the code tags however not keeping the spaces? x (0 spaces) x (1 space) x (2 spaces) x (3 spaces)
...but apparently, not when you're a Java programmer. Look at BIT_POS_MASKS and readBit(). :facepalm:
Name:
Anonymous2017-07-14 6:27
>>1 why does your function take a pointer to cunts?
Name:
Anonymous2017-07-16 1:43
>>1 Why are your variable names so compressed? Also I thought you were joking when you said you use 1 space indentation... You know almost no one does this, right?
Name:
Anonymous2017-07-16 2:28
>>26 Frozenvoid does it too Or I think he just leaves it all on one line
Name:
Cudder !cXCudderUE2017-07-16 3:16
>>26 You're supposed to focus on the structure, not the names. This is meant to be the complete opposite of the ENTERPRISE BULLSHITE tiringly verbose tripe that gets churned out in bulk by clueless codemonkeys (like >>24) which says a lot without doing much.
One space is sufficient. No "partial" indents (a line is always in one indent level), all the size advantages of tabs combined with the fixed-width-ness of spaces, easy to see the level without multiplying or dividing.
Name:
Anonymous2017-07-16 3:38
>>27 I don't indent code and find the idea ridiculous, but sometimes use editors which add "indentation level"(which i don't fix).
>>31 I don't write pretty novels. I'm not a code artisan. I don't need a style guide. I don't need your rules about indentation. All this superfluous mental garbage(tabs vs spaces, one true brace, the right font) is a distraction from actual programming.
>>32 You don't need people reading your crap either.
Name:
Anonymous2017-07-16 16:26
Indentation is nothing but an instrument of code oppression created by the so-called ``code artisans'', who believe that the importance of code is determined by their level of indentation. Break your code free from the oppression of the patriarchic code artisans, comrades! Programmers of the world, unite and stop indenting! All lines of code are equal!