hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Patience
Goto page Previous  1, 2
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
Patience
Author Message
KindeX



Joined: 22 Jul 2010
Posts: 2

Post Reply with quote
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.
Wed Sep 15, 2010 1:32 pm View user's profile Send private message
AMindForeverVoyaging
Forum Admin


Joined: 28 May 2011
Posts: 493
Location: Germany

Post Reply with quote
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:

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?
Sat Jul 02, 2011 3:18 pm View user's profile Send private message
Karian



Joined: 09 Jan 2008
Posts: 75

Post Reply with quote
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.
Mon Jul 04, 2011 10:59 am View user's profile Send private message
AMindForeverVoyaging
Forum Admin


Joined: 28 May 2011
Posts: 493
Location: Germany

Post Reply with quote
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:

Random rand_sequence = new Random(739391L);


and then it would run - slowly Wink 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.
Mon Jul 04, 2011 3:08 pm View user's profile Send private message
tripleedged



Joined: 16 Apr 2010
Posts: 10

Post Reply with quote
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...
Tue Jul 19, 2011 9:04 pm View user's profile Send private message
moose



Joined: 16 Jul 2010
Posts: 67

Post Reply with quote
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).
Tue Aug 30, 2011 3:56 pm View user's profile Send private message
wischi



Joined: 08 Apr 2012
Posts: 9

Post Reply with quote
need some help Smile

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

am i wrong? thx in advance
Fri Apr 13, 2012 11:50 am View user's profile Send private message
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
wischi wrote:
need some help Smile

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

am i wrong? thx in advance

I admit my evidence is limited, but I suspect your answer is wrong Smile sorry!

_________________
There is no spoon.
Fri Apr 13, 2012 7:12 pm View user's profile Send private message
magnus



Joined: 05 Mar 2009
Posts: 20

Post Reply with quote
Takes ~7 Seconds with the right optimizations Wink
Mon Apr 23, 2012 8:40 am View user's profile Send private message
eduarrrd



Joined: 06 Aug 2012
Posts: 3

Post Reply with quote
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.
Sun Feb 10, 2013 4:53 am View user's profile Send private message
rabuf



Joined: 09 Jul 2011
Posts: 2

Post Reply with quote
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)?
Thu Apr 25, 2013 9:23 pm View user's profile Send private message
AMindForeverVoyaging
Forum Admin


Joined: 28 May 2011
Posts: 493
Location: Germany

Post Reply with quote
Well several people solved it after eduarrd's post, so it should be doable still.
Fri Apr 26, 2013 12:07 am View user's profile Send private message
rabuf



Joined: 09 Jul 2011
Posts: 2

Post Reply with quote
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.
Fri Apr 26, 2013 5:16 am View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.