I've just solved this challenge. The answer is YES - the only one first generated number is correct answer. So, use proper random generator.KindeX wrote:So the question is if the checker accepts only one predefined correct answer, or checks every every answer with some algorithm.
Patience
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany
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:
Should I use a different decompiler (this was done with jd-gui-0.3.3.windows), or a different version of the Java SDK?
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);
^
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany
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
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.
Now, it's easy to fix it to something like
Code: Select all
Random rand_sequence = new Random(739391L);
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.
-
- Posts: 10
- Joined: Fri Apr 16, 2010 11:24 pm
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...
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...
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.
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.
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)?
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)?
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany