Programming Diversions

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Secret code

    7 answers - 2037 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I found this snippet of code which sets out deliberately to confuse.

    Can you find out what the code does ? Eventually I'll post where I found this from and give credit where it is due.


    code:


    main(l
    ,a,n,d)char**a;{
    for(d=atoi(a[1])/10*80-
    atoi(a[2])/5-596;n="@NKA\
    CLCCGZAAQBEAADAFaISADJABBA^\
    SNLGAQABDAXIMBAACTBATAHDBAN\
    ZcEMMCCCCAAhEIJFAEAAABAfHJE\
    TBdFLDAANEfDNBPHdBcBBBEA_AL\
    H E L L O, W O R L D! "
    [l++-3]; )for(;n-->64; )
    putchar(!d+++33^
    l&1);}


    The code is in C. The key is in

    char a[ ] = "ABCD"; /* string representation */
    char b[ ] = "\x41\x42\x43\x44"; /* hexadecimal representation */
    char c[ ] = "\101\102\103\104"; /* octal representation */
    char d[ ] = "A" "B" "C" "D"; /* using string properties */
    char e[ ] = {'A', 'B', 'C', 'D', ' \0'}; /* using char propery */

    In C all the above strings a, b, c, d and e represent ABCD.

    Please post the output also.
    I'll post the answer soon. I thought I'd just give someone the pleasure of finding the answer.

    code:

    main(l,a,n,d)char**a; {
    for(d=atoi(a[1])/10*80-atoi(a[2])/5-596;
    n="@NKA\
    CLCCGZAAQBEAADAFaISADJABBA^\
    SNLGAQABDAXIMBAACTBATAHDBAN\
    ZcEMMCCCCAAhEIJFAEAAABAfHJE\
    TBdFLDAANEfDNBPHdBcBBBEA_AL\
    H E L L O, W O R L D! " [l++-3];
    )
    for(;n-->64; )
    putchar(!d+++33^l&1);}


    Here is the code again, resembling code this time in case people were trying to read it South Pole top-wise, following Bert's advice about globes.

    Run the program as <program name> int1 int2
    where int1 and int2 are integers between -180 and 180.
    Ok, Ok , the integers are latitude,longitude and the program gives their location in a way.
    Try 38 and -122 for San Francisco.

    regards

    [ September 01, 2003: Message edited by: HS Thomas ]

  • No.1 | | 255 bytes | |

    The solution is in danger of going unposted.
    Well, I've tried and don't get any output and can't explain how it works.

    There's no fun in posting a solution when no one has tried.

    regards

  • No.2 | | 159 bytes | |

    I don't know how it works, but the output is a (flat) map of the world.

    It is quite clever - I just wish I was clever enough to understand how it worked.

  • No.3 | | 472 bytes | |


    At least you got it to run.
    Quite an OBE (Out of Body Experience).

    I better post the link to the solution then.
    Enjoy!

    Obfuscated Code

    Notice how the graemlins lie in an orbit like planets round the world.
    Another OBE!

    regards

    [ September 02, 2003: Message edited by: HS Thomas ]

  • No.4 | | 116 bytes | |

    It runs OK on Windows XP, but crashes on Win98.

    This is a real memory jog/guess - 16 bit unicode Vs 8 bit unicode?

  • No.5 | | 119 bytes | |

    Well ,I'm trying to run it on XP. Unless the output is being directed elsewhere, I'm not seeing any.

    regards

  • No.6 | | 164 bytes | |

    I use the Dev-C++ compiler, so I had to add
    getchar();
    at the end, otherwise it just ran/closed.

    [ September 03, 2003: Message edited by: Michael Dunn ]

  • No.7 | | 74 bytes | |

    Thanks Michael, I'll give that a shot when I have some time.

    regards

Re: Secret code


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Programming Diversions"

JAVA.JOYCODING.COM