Guess the number/With feedback (player): Difference between revisions

Content added Content deleted
(Added MATLAB example)
m (MATLAB: More input options)
Line 1,148:
score = input(sprintf( ...
'Is %d too high (H), too low (L), or equal (E)? ', guess), 's');
if any(strcmpi(score, {'h' 'hi' 'high' 'too high' '+'}))
highVal = guess-1;
nGuesses = nGuesses+1;
elseif any(strcmpi(score, {'l' 'lo' 'low' 'too low' '-'}))
lowVal = guess+1;
nGuesses = nGuesses+1;
elseif any(strcmpi(score, {'e' 'eq' 'equal' 'right' 'correct' '='}))
fprintf('Yay! I win in %d guesses.\n', nGuesses)
done = true;