Thread: Guess the code!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    The below two programs are based on a common theme.

    Code:
    unsigned i, j;
    for(i = 64; i; --i) {
        for(j = 0; j < 64; ++j)
            putchar("-#"[!(i - 1 & j)]);
        putchar('\n'); }

    This one is completely incomprehensible. The program is summarized in a one-word C-style comment which makes the last line exactly 80 characters long ("10-letters" is a placeholder); you can try guessing it instead

    Code:
    int main(){char*c=calloc(102,1);++c;*c+=8;while(*c){--*c;--c;*c+=4;c+=2;*c+=4;++
    c;++*c;c-=2;}c+=2;*c+=2;++c;*c+=2;c-=4;while(*c){--*c;while(*c){--*c;++c;++*c;--
    c;}++c;while(*c)--*c,++c,putchar(*c),c-=2,++*c,++c;c+=3;while(*c){--*c;while(*c)
    --*c,++c,++*c,--c;++*c;++c;while(*c){--c;++*c;++c;*c+=7;while(*c)--*c,++c,*c+=6,
    --c;++c;--*c;putchar(*c);--*c;while(*c)--*c,--c,*c+=2,++c;--c;putchar(*c);while(
    *c){--*c;}}*c+=2;--c;while(*c)--*c,++c,--*c,--c;*c+=2;++c;while(*c){--c;--*c;++c
    ;*c+=7;while(*c)--*c,++c,*c+=4,--c;++c;putchar(*c);putchar(*c);while(*c)--*c;--c
    ;}c+=2;}++*c;c-=3;while(*c){--*c;while(*c){--*c;++c;++*c;--c;}++*c;++c;while(*c)
    {--*c;--c;++*c;c+=3;--*c;while(*c)--*c,++c,++*c,--c;*c+=2;++c;while(*c)--*c,--c,
    --*c,++c;c-=3;}c-=4;}c+=2;putchar(*c);c-=3;}getchar();return 0;}/* 10-letters */
    It makes several nonportable assumptions: unsigned default char or two's complement, ASCII, and general reliability of memory alloc. It is, however, written in a small number of simple, easy-to-understand operations, thus increasing its accessibility to beginning programmers.
    Last edited by jafet; 11-08-2006 at 04:31 AM.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. banking2
    By sweet2awy in forum C++ Programming
    Replies: 7
    Last Post: 08-01-2003, 03:01 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM