Ad
  • Custom User Avatar

    The description doesn't need to be updated because:
    Ad. 1 Description says you have to "break a code of 3 digits" not numbers, and digits are integers;
    Ad. 2 Digits are numbers but numbers aren't necessarily a digits, so they have their min/max value (look at the definition of digit)

  • Custom User Avatar

    I think the description could be expanded to answer:

    • Are the numbers always integers or can then be any number?
    • If there a min/max for the "digits"?

    Also, I imagine that this will require me to store some global state which I need to clear each time my function is called with null. I agree with @arnedag that it would probably be cleaner if you passed the guess function as the parameter, then returned indications on a bad guess, returned true on success, or threw an error if we made too many guesses.

    Here is an example of what that might look like:

    function breakCode(makeGuess) {
      var guess = [x, y, z];
      var indications;
      
      while (true !== (indications = makeGuess(guess))) {
        // use indications to update guess
      }
    }