Ad
  • 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
      }
    }