Ad
  • Default User Avatar

    Yes, I mean that it is probably better to say something like 'change that method'.
    Sure I need more experience to get such things better )).

  • Default User Avatar

    it seems the test for 1000 has invalidated a great many solutions. should this test be removed ?

  • Custom User Avatar

    OK I have it now. 10 guesses is sufficent to solve any number between 1 and 1000!

    Thanks for your help.

  • Default User Avatar

    yes, there is a more efficient algorithm. you should not be picking numbers randomly.

  • Custom User Avatar

    I then refine my guess to pick a random number between 1 and 500.

    Wrong. There should be no randomness involved in your algorithm. Otherwise, you're right: you may need more than 10 guesses.

    After the first guess, why do you need to pick a random number? Why did you pick 500 initially?

  • Custom User Avatar

    OK,

    So I have 10 guesses to figure out a number between 1 and 1000: Lets say the number to be guessed is 345.

    Now my first guess is 500 obviously too high, I then refine my guess to pick a random number between 1 and 500.

    I continue refining the range of the guess depending on the result of the previous guess. So for example, my second guess is 200 which is too low then my third guess will be between 200 and 500. One can easily use up the 10 guesses without reaching the correct number in 10 guesses. It is not possible to make it more efficent than that!

    So my issue is still boils down to what to I do if I don't guess the correct number within 10 guesses?

  • Custom User Avatar

    The name depends on the language.

  • Default User Avatar

    To me the description is not clear. It says to write method 'get_number()', but there is already method 'getNumber()' (without underscore). Cycle in it runs for 1000 times when there are only 10 attempts. Those things are confusing.