F
Francois Grieu
/*
Two independent puzzles about the present C program, which
compiles and produce OK when run (in a hosted environment).
1) Shorten as much as possible the line following the comment,
keeping the rest of the program unmodified, so that it still
produce OK.
2) Make the program as short as possible (ignoring spaces and
end-of-line), without changing what happens when the line
following the comment is changed.
Francois Grieu
*/
#define
P(n)(((n)&1)+5-!((n)&2)-!((n)&4)-!((n)&8)-!((n)&16)-!((n)&32)+((n)>>6)-((n)>>7))
#include <stdio.h>
int main(void)
{
int j;
for( j = 255; j -= !(P(0?0:j&(j-1))+1+(-P(j))); );
puts("OK");
return 0;
#if !P(0)
}
#endif
Two independent puzzles about the present C program, which
compiles and produce OK when run (in a hosted environment).
1) Shorten as much as possible the line following the comment,
keeping the rest of the program unmodified, so that it still
produce OK.
2) Make the program as short as possible (ignoring spaces and
end-of-line), without changing what happens when the line
following the comment is changed.
Francois Grieu
*/
#define
P(n)(((n)&1)+5-!((n)&2)-!((n)&4)-!((n)&8)-!((n)&16)-!((n)&32)+((n)>>6)-((n)>>7))
#include <stdio.h>
int main(void)
{
int j;
for( j = 255; j -= !(P(0?0:j&(j-1))+1+(-P(j))); );
puts("OK");
return 0;
#if !P(0)
}
#endif