Live data from Hacker News

Java Puzzle: Square Root

corner.squareup.com

21–30 of 61 posts

Re: Java Puzzle: Square Root

#21
post #4

The only possibilities seem to be a timing attack, exploiting a bug or taking advantage of an implementation that puts the dividend value in the exception when dividing by zero. I'm not sure anyone will bother writing the timing attack since he apparently gives out no prize.

Unless there's something in Java that allows you to manipulate private copies of private variables without access to the stored values.

I'm familiar with Java, but not so familiar that I can state with authority that such a thing is impossible.

Re: Java Puzzle: Square Root

#22

Earlier quoted context omitted.

There is a really big number you don't know. You should get the square root for it.

So why are people talking about vulnerabilities and 'timing attacks' then? and how are you supposed to get the square root of a number you dont know..

[deleted]

Re: Java Puzzle: Square Root

#27
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. :)

Re: Java Puzzle: Square Root

#30
I hate to break it to you but "n" is not final. Hence, you can reassign any BigInteger to it. Why not just set n = 9 and the root = 3...

Immutability is your friend. Use it or lose it.

Post reply on HN