I attempted to adapt your Perl to C, but I made a mistake somewhere. I don't know if you can see the problem, but I can't and I need to move on:
U8 *firstIdx( U8 N, U8 M ) {
U32 i;
U8 *a = malloc( M );
for( i = N - M; i < N; ++i ) a[ i - M + 1 ] = i;
return a;
}
U8 *nextIdx( U8 N, U8 M, U8 *idx ) {
U32 i = M - 1, j;
if( idx[ i ] == i ) return NULL;
while( i > 0 && idx[ i ] - idx[ i - 1 ] == 1 ) i--;
--idx[ i ];
for( j = i+1; j < M; ++j ) idx[ i ] += N - idx[ M - j + i ];
return idx;
}
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.