Silly Mr. Arndt, the proper de-obfuscation is clearly this: (defun sierpinski (n) (do ((r n (1- r))) ((minusp r)) (princ (make-string (1+ r) :initial-element #\space)) (dotimes (c (- n r) (terpri)) (format t "~:[ #~; `~]" (zerop (logand c r)))))) (sierpinsky 32) ;-) Sincerely yours, Robert Smith On 7/18/2011 11:00 AM, Joerg Arndt wrote:
After de-obfuscation we see that the one interesting trick is to use the test whether the bitset of bit-and(r,c) is empty for determining the Pascal triangle mod 2:
-----------------
// gcc -O2 -W -Wall -std=c99 sierpinsky.c&& ./a.out
#include<stdio.h>
#if 0 main(c,r){for(r=32;r;)printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");} #else
int main() { int N = 32; int r = N; do // rows: { --r; for (int c=0; c<=r; ++c) printf(" "); // padding to make triangle
for (int c=0; c<N-r; ++c) // columns: { if ( (c& r) != 0 ) printf(" `"); else printf(" #"); } printf("\n"); } while ( r != 0 ); } #endif
/* Orig output, (mine has the bottom row added):
# # # # ` # # # # # # ` ` ` # # # ` ` # # # ` # ` # ` # # # # # # # # # # ` ` ` ` ` ` ` # # # ` ` ` ` ` ` # # # ` # ` ` ` ` ` # ` # # # # # ` ` ` ` # # # # # ` ` ` # ` ` ` # ` ` ` # # # ` ` # # ` ` # # ` ` # # # ` # ` # ` # ` # ` # ` # ` # # # # # # # # # # # # # # # # # # ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` # # # ` ` ` ` ` ` ` ` ` ` ` ` ` ` # # # ` # ` ` ` ` ` ` ` ` ` ` ` ` ` # ` # # # # # ` ` ` ` ` ` ` ` ` ` ` ` # # # # # ` ` ` # ` ` ` ` ` ` ` ` ` ` ` # ` ` ` # # # ` ` # # ` ` ` ` ` ` ` ` ` ` # # ` ` # # # ` # ` # ` # ` ` ` ` ` ` ` ` ` # ` # ` # ` # # # # # # # # # ` ` ` ` ` ` ` ` # # # # # # # # # ` ` ` ` ` ` ` # ` ` ` ` ` ` ` # ` ` ` ` ` ` ` # # # ` ` ` ` ` ` # # ` ` ` ` ` ` # # ` ` ` ` ` ` # # # ` # ` ` ` ` ` # ` # ` ` ` ` ` # ` # ` ` ` ` ` # ` # # # # # ` ` ` ` # # # # ` ` ` ` # # # # ` ` ` ` # # # # # ` ` ` # ` ` ` # ` ` ` # ` ` ` # ` ` ` # ` ` ` # ` ` ` # # # ` ` # # ` ` # # ` ` # # ` ` # # ` ` # # ` ` # # ` ` # # # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` # ` #
*/
-----------------
May use this to show my students how hard to read badly documented and formatted code can be.
* quad<quadricode@gmail.com> [Jul 18. 2011 18:28]:
main(c,r){for(r=32;r;)printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
Cheers!
-Robert
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun