Krocker @ Sat Oct 15, 2011 7:59 am wrote:
as for how many guesses b/t 1 to 100, i would say 100 guesses?
Too high. Which number would I have to guess for you to take 100 tries?
e.g. Guess "99". You are either:
- right. Done in 1 move.
- too low. Then you know the answer is 100. Done in 2 moves.
- too high. Linearly try every number down. Done in 99 moves.
(though by the same approach "99" also too high)
Krocker @ Sat Oct 15, 2011 7:59 am wrote:
but i dont see how that will help me learn delays and random number generaters. also i was looking at Math.Random(), but i not sure how to use it.
It's an important problem to be able to solve; basis of many algorithms.
Also, docs for Math.random() are pretty straight forward. http://download.oracle.com/javase/6/docs/api/java/lang/Math.html#random()
Quote:
public static double random()
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.
What are you not sure about?