Results 1 to 17 of 17

Thread: Contest :-)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432

    Post Contest :-)

    Ok Guys a friend of mine wrote this code and i wanna see if we have some good C++ programmers in this forum :-)

    Anyone that can figure out how this code works and post a good explanation WINS



    Code:
    #include <stdio.h>
    #define _____ char
    #define ____ int
    #define _ main
    _____ ______[]="]a`z)`z)Clp. z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})
     ;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm
    f%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";_(____ __, _____ ** _______){__>0?_(0,(_____**)______) (_____*)_______)[-__] == '\0'?putchar(10) utchar(((_____*)_______)[-__]^9)?_(--__,_______):_(__,++_______);}

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It doesn't even compile like that so I'm doing the expansions by hand %-)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Ooh, recursive main(), these are always fun...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    #include <stdio.h>
    
    char str[] = "]a`z)`z)Clp. z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})\n ;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm\nf%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";
    
    main (int argc, char  ** argv) {
        char* p = str;
        while(*p) {
            putchar(*p ^ 9);
            ++p;
        }
    }
    Recursion removed

    What I did was look for where it was going, and with the calling of main with argc increased each time, looks like it's using main to loop through a string. That done, it XORs the character with 9 and prints it. I also had to replace the actual newlines in the string with '\n' characters.

    This gives the message:
    Code:
    This is Jey')s Obfuscated Hello World example! It is copyright )2001 by Jeyasankar Kottalam.
    
    Without further ado, here's the message: HELLO, WORLD!
    Not bad considering the code you gave doesn't compile
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Hmm, just noticed those spurious brackets...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    #include <stdio.h>
    
    const char str[] = "]a`z)`z)Clp.z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})\n;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm\nf%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";
    
    int main (int argc, const char **argv) {
        const char* p = str;
        
        while(*p) {
            putchar(*p ^ 9);
            ++p;
        }
        
        putchar('\n');
    }
    Done.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Woah, why write such a thing?

    I guessed at how to solve this, but I'm sure I'd have been too lazy...

    Good job, parksie.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    btw it is less a matter of being a good C++ programmer, but more of knowing such obscure things like trigraph sequences.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I have extended the thing a little bit.
    But I mostly copied the original, so it still won't compile.
    Code:
    ??=include &lt;stdio.h&gt;
    ??=define _____ char
    ??=define ____ int
    ??=define _ main
    _____ ______??(??)="??)a`z)`z)Clp. z)Fko??!zjh??>lm)Aleef)??'f??<em)lqhdyel()@??>)`z)jfyp??<`na??>)
     ;998)kp)Clphzhgbh??<)Bf??>??>hehd'??/3??/3??'`}af??!??>)o??!??<??>al??<)hm
    f%)al??<l.z)??>al)dlzzhnl3)ALEEF%)??'F??(EM((";____ _(____ __, _____ ** _______)??<__&gt;0?_(0,(_____**)______) (_____*)_______)??(-__??) == '??/0'?putchar(10) utchar(((_____*)_______)??(-__??)??'9)?_(--__,_______):_(__,++_______);??>
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The "utchar" is also a typo.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by CornedBee
    Woah, why write such a thing?

    I guessed at how to solve this, but I'm sure I'd have been too lazy...

    Good job, parksie.
    Agree =). But obfuscating hello world isnt a big deal... Obfuscate Halflife =P.

    Z.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    Nice Job parksie
    :-)

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I'm suspicious though. How did your friend write it? You haven't been allowed to get away with code like that without specifically compiling it as "old" C...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    I dont know ill refer him to this forum and have him post an answer

  15. #15
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    I wrote this code once. It's legal C++.
    Don't cheat by running it!

    Code:
    ??=define e(r)e??=#??=??=??=??=#??=r
    ??=define b(e)""??=#??=e??=#""
    ??=define t(i)()r(??<)#??=??/
    e(t)#??=urn(i??=#??=??=??/
    b(y)??=??=i#??="")+((3??'(0??=#x2??!1))??!
    ??=define r(i)i#??=#??=??=??=r
    ??=include<iostream>
    ??=define i(i)in??=#t ma??=??=in()??<??/
    st??=??=d::cou??=??=t<#??=r(<i;)??=#e(t)#??=ur#??=n 0??'0
    ??=define d(t) i(b(h)??=#"i"??=#b(??/?)??/
    <??=#<std::??=??=e(ndl<)??=??=<'b'<#??=<e(r)())
    r(cha)*r(e) t(b(e)"??/41")2);??>d(??!/\??\
    ??=ine i(i)in??=#t ma??=??=in)??!0;??>
    When I first wrote it, it output Dutch, it took me 30 minutes just to convert it to English.

    Note to self: Never write code like that again!
    Last edited by twanvl; Oct 18th, 2002 at 05:05 PM.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Most of it's just trigraphs.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  17. #17
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    You're right, I wrote this code when I learned about trigraphs (found a link in MSDN library) Without the trigraphs it's just a bunch of macros

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width