I'm surprised nobody's given the obvious algorithm yet: while(i Before anyone complains, this algorithm is correct and does not break any of the rules as far as I can tell. :) I think the timing attack is probably what he's really looking for. Edit: as mattvanhorn pointed out, answer() is void, but that's ok... changed to a "constant time" algorithm. :)
The BigInteger is really big. An i7 does about 109 gigaFLOPS, or 109 operations per nanosecond. [1] Suppose we can do 1 guess per operation. There are 2^10,000 possible roots. [2] 2^10,000 / 109 nanoseconds is 5.804×10^2991 years. [3] The stars will burn out before you brute force it. [1] http://en.wikipedia.org/wiki/FLOPS [2] http://bit.ly/ZIWkkt (parens in the original link) [3] http://www.wolframalpha.com/input/?i…
Java Puzzle: Square Root
51–60 of 61 posts
Re: Java Puzzle: Square Root
#52Re: Java Puzzle: Square Root
#53Earlier quoted context omitted.
...and that you can remove all the existing ones and insert your own.
You can't change Providers while running under the SecurityManager he specifies you must use in the rules. SecurityManager.checkSecurityAccess(java.lang.String) is called if you try and mess with the Providers.
Re: Java Puzzle: Square Root
#54Re: Java Puzzle: Square Root
#55Re: Java Puzzle: Square Root
#56is using the ASM library not a legitimate way or would that violate the rules in some way?
Re: Java Puzzle: Square Root
#57Force a race condition on the variable `root'. if (n.divide(root).equals(root)) { Try to set it to 2^20001 on the first funcall and 0 on the second.
Re: Java Puzzle: Square Root
#58I'm surprised nobody's given the obvious algorithm yet: while(i Before anyone complains, this algorithm is correct and does not break any of the rules as far as I can tell. :) I think the timing attack is probably what he's really looking for. Edit: as mattvanhorn pointed out, answer() is void, but that's ok... changed to a "constant time" algorithm. :)
Re: Java Puzzle: Square Root
#59Consider that SecureRandom is really a facade around multiple providers that can plug in varying implementations. :)
Trying to write a timing attack sounds much more interesting.
Re: Java Puzzle: Square Root
#60I'm surprised nobody's given the obvious algorithm yet: while(i Before anyone complains, this algorithm is correct and does not break any of the rules as far as I can tell. :) I think the timing attack is probably what he's really looking for. Edit: as mattvanhorn pointed out, answer() is void, but that's ok... changed to a "constant time" algorithm. :)
answer() has a void return, although I suppose you might be able to watch System.out to see if it worked.