Page 2 of 2

Posted: Wed Sep 15, 2010 1:32 pm
by KindeX
KindeX wrote:So the question is if the checker accepts only one predefined correct answer, or checks every every answer with some algorithm.
I've just solved this challenge. The answer is YES - the only one first generated number is correct answer. So, use proper random generator.

Posted: Sat Jul 02, 2011 3:18 pm
by AMindForeverVoyaging
I'm wondering - does this depend on a certain version of Java? I am using build 1.6.0_26-b03 and when I try to compile again the decompiled Patience.class, I get two errors:

Code: Select all

Patience.java:9: incompatible types
found   : java.util.Random
required: java.lang.String[]
    paramArrayOfString = new Random(739391L);
                         ^
Patience.java:14: cannot find symbol
symbol  : method nextLong()
location: class java.lang.String[]
      while ((l = paramArrayOfString.nextLong()) < 0L);
                                    ^
Should I use a different decompiler (this was done with jd-gui-0.3.3.windows), or a different version of the Java SDK?

Posted: Mon Jul 04, 2011 10:59 am
by Karian
No idea what causes the problem exactly, since I don't know which steps you took exactly, but it looks like a bit of java Knowledge can solve your problem.

Posted: Mon Jul 04, 2011 3:08 pm
by AMindForeverVoyaging
I thought that when you decompile a given Java .class file, and then re-compile it again, you would get a class file which can be executed. Not so here, where the re-compilation fails with said errors.

Now, it's easy to fix it to something like

Code: Select all

Random rand_sequence = new Random(739391L);
and then it would run - slowly ;) Still I don't really get why the decompilation leads to erroneous source code.

Now, after fixing that I tried to replace the "BigInteger" with "long", but that gave me an error because of the string index array in the do...while loop taking on negative values after a certain amount of iterations. Well, I'll have to find a different approach it seems.

Posted: Tue Jul 19, 2011 9:04 pm
by tripleedged
This one was quite funny...
I thought I had tweaked it enough to run it in an acceptable amount of time. After some minutes of running I got curious if I missed some detail and wanted to get some of the original numbers to check my calculation. After I restored the initial (just little improved) code I wanted to stop the program and it just showed the solution...
Phew, if I had given up few seconds early, I still would not have solved it...

Posted: Tue Aug 30, 2011 3:56 pm
by moose
Is it enough to solve the 20,000-for-loop to a multiplication and an addition? Or is more tweaking required? It just runs. I think I let it try for 30 min (so until 18:25).

Posted: Fri Apr 13, 2012 11:50 am
by wischi
need some help :-)

after some math-hacks i figured out the rnd-number which passes the while-condition, but submit the answer ends in 'incorrect' :-( FUUUU

am i wrong? thx in advance

Posted: Fri Apr 13, 2012 7:12 pm
by laz0r
wischi wrote:need some help :-)

after some math-hacks i figured out the rnd-number which passes the while-condition, but submit the answer ends in 'incorrect' :-( FUUUU

am i wrong? thx in advance
I admit my evidence is limited, but I suspect your answer is wrong :) sorry!

Posted: Mon Apr 23, 2012 8:40 am
by magnus
Takes ~7 Seconds with the right optimizations ;-)

Posted: Sun Feb 10, 2013 4:53 am
by eduarrrd
Is the challenge really working?

I decompiled the code, optimized it and let it run (<10min to finish). However, the challenge is not accepting my result. To make sure I got it right, I kept both the original and my version of the relevant part and looked at the difference between the two results for half an hour (always 0). Could it be a java version issue (running 1.7.0_06 (IcedTea7 2.3.4))? The number I'm getting is 9245[10 digits]7183.

Posted: Thu Apr 25, 2013 9:23 pm
by rabuf
Same issue as eduarrd. Making some optimizations to the math involved and running it I got an answer after a few minutes that was not accepted. I'm guessing the seed to the RNG is important and I kept it, but unfortunately it seems that my version is generating a different sequence.

Java version, on OS X:

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)

Any suggestions besides my next step (run it printing out value that satisfies the test and try them all)?

Posted: Fri Apr 26, 2013 12:07 am
by AMindForeverVoyaging
Well several people solved it after eduarrd's post, so it should be doable still.

Posted: Fri Apr 26, 2013 5:16 am
by rabuf
Well, disregard my previous comment. I did something to screw up the code in my attempt to make it run quicker. Tested the RNG across several java versions and it produced the same results as my original run.