Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Obfuscated code contest

  1. #1
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Obfuscated code contest

    A small twist to the traditional obfuscated coding contest. Without running/refactoring/formatting this code, figure out what it does (it's something fairly simple).

    public class Obfuscated
    {
    public static void main(String[] args)
    {long ___;long _____[]=new long[0x10];
    {_____[0]=System.nanoTime();
    ___=System.nanoTime()%9223372036854773232L;
    for(int _______=0;_______<0x10;++_______)
    {_____[_______]=(9223372036854773232L*_____[_______]+___&Long.MAX_VALUE)%9223372036854775807L;
    ___=9223372036854773232L*_____[_______]+___;}}
    int ______=0;long _______=0;long ________=0;
    for(;________<0xFFFFFFL;++________)
    {long _________=(9223372036854773232L*_____[______]+___&Long.MAX_VALUE)%9223372036854775807L;
    ___=9223372036854773232L*_____[______]+___;
    _____[______]=_________;
    double __________=(double)_____[______]/Long.MAX_VALUE;
    ++______;
    if(______>=0x10)
    {______=0;}
    _________=(9223372036854773232L*_____[______]+___&Long.MAX_VALUE)%9223372036854775807L;
    ___=9223372036854773232L*_____[______]+___;
    _____[______]=_________;
    double ___________=(double)_____[______]/Long.MAX_VALUE;
    ++______;
    if(______>=0x10)
    {______=0;}
    if(Math.sqrt(__________*__________+___________*___________)<=1)
    {++_______;}}
    System.out.println(4.*_______/________);}}

    The first correct answer wins bragging rights and a free copy of the Eclipse IDE
    Last edited by helloworld922; April 21st, 2011 at 08:59 PM.


  2. #2
    Member OutputStream's Avatar
    Join Date
    Apr 2011
    Posts
    32
    My Mood
    Fine
    Thanks
    1
    Thanked 4 Times in 3 Posts

    Default Re: Obfuscated code contest

    Ugh my head
    But to me, it seems as if you are dividing 0/0, but you are also multiplying a float... Hmm, does it print positive infinity?

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Obfuscated code contest

    nope The algorithms I chose are those which people normally don't work with directly and can't have the results worked out by hand. However, I'm confident that someone will eventually be able to figure it out.

    edit:

    hmm, I guess I didn't realize this before but there's something wrong with part of the code. However, despite this, the code is still able to converge on the correct answer (hint hint).
    Last edited by helloworld922; April 22nd, 2011 at 09:32 AM.

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Obfuscated code contest

    I really thought someone would have figured out what this code does.

    Well, here is the spoiler: It calculates the value of pi. I implemented a small CMWC random number generator, but I kind of botched the generator code (there were quite a few mistakes). However, the generator was of sufficient quality that it could still calculate pi (it's actually kind of funny how bad the generator can be and still get decent results for pi).

Similar Threads

  1. INSOMNIA::THE MIDNIGHT PROGRAMMING CONTEST.
    By ATUL10 in forum The Cafe
    Replies: 1
    Last Post: March 25th, 2010, 01:03 PM
  2. Replies: 0
    Last Post: January 15th, 2010, 02:48 AM