Cody

# Problem 44630. Guess the number I'm thinking of

Solution 2569626

Submitted on 16 Jun 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
assessFunctionAbsence({'rng', 'RandStream'}, 'FileName','myGuess.m')

2   Pass
for j = 1 : 1000 numberToBeGuessed = randi(10); gOO = randperm(10, 2); mG = myGuess(gOO); assert( mG >= 1 & mG <= 10 , 'Out of requested range.' ) u = unique( floor([gOO mG]) ); assert( length(u) == 3 , 'Your guess must not have been already chosen.' ) end;

gOO = 7 10 y = 9 gOO = 8 9 y = 9 gOO = 2 3 y = 3 gOO = 4 9 y = 7 gOO = 2 10 y = 6 gOO = 1 3 y = 2 gOO = 5 10 y = 8 gOO = 1 7 y = 4 gOO = 3 7 y = 5 gOO = 1 9 y = 5 gOO = 2 5 y = 4 gOO = 4 5 y = 5 gOO = 1 3 y = 2 gOO = 3 9 y = 6 gOO = 7 8 y = 8 gOO = 1 4 y = 3 gOO = 3 6 y = 5 gOO = 6 8 y = 7 gOO = 4 5 y = 5 gOO = 4 9 y = 7 gOO = 5 6 y = 6 gOO = 1 7 y = 4 gOO = 5 6 y = 6 gOO = 2 5 y = 4 gOO = 3 5 y = 4 gOO = 3 6 y = 5 gOO = 1 7 y = 4 gOO = 1 10 y = 6 gOO = 1 7 y = 4 gOO = 5 10 y = 8 gOO = 3 10 y = 7 gOO = 4 5 y = 5 gOO = 7 9 y = 8 gOO = 4 6 y = 5 gOO = 1 8 y = 5 gOO = 1 10 y = 6 gOO = 1 8 y = 5 gOO = 6 7 y = 7 gOO = 7 8 y = 8 gOO = 5 10 y = 8 gOO = 3 8 y = 6 gOO = 1 8 y = 5 gOO = 5 10 y = 8 gOO = 1 4 y = 3 gOO = 1 2 y = 2 gOO = 3 8 y = 6 gOO = 2 8 y = 5 gOO = 3 8 y = 6 gOO = 3 5 y = 4 gOO = 4 8 y = 6 gOO = 1 2 y = 2 gOO = 3 4 y = 4 gOO = 3 6 y = 5 gOO = 1 9 y = 5 gOO = 7 8 y = 8 gOO = 1 7 y = 4 gOO = 2 7 y = 5 gOO = 2 3 y = 3 gOO = 8 10 y = 9 gOO = 3 10 y = 7 gOO = 3 8 y = 6 gOO = 4 8 y = 6 gOO = 7 8 y = 8 gOO = 2 8 y = 5 gOO = 1 7 y = 4 gOO = 1 9 y = 5 gOO = 6 7 y = 7 gOO = 1 2 y = 2 gOO = 5 9 y = 7 gOO = 5 8 y = 7 gOO = 6 9 y = 8 gOO = 2 5 y = 4 gOO = 3 10 y = 7 gOO = 6 9 y = 8 gOO = 3 7 y = 5 gOO = 3 10 y = 7 gOO = 1 4 y = 3 gOO = 5 7 y = 6 gOO = 9 10 y = 10 gOO = 5 9 y = 7 gOO = 9 10 y = 10 gOO = 4 5 y = 5 gOO = 2 10 y = 6 gOO = 4 8 y = 6 gOO = 5 6 y = 6 gOO = 3 4 y = 4 gOO = 2 6 y = 4 gOO = 3 10 y = 7 gOO = 1 8 y = 5 gOO = 1 9 y = 5 gOO = 3 8 y = 6 gOO = 3 4 y = 4 gOO = 1 10 y = 6 gOO = 7 10 y = 9 gOO = 8 10 y = 9 gOO = 2 9 y = 6 gOO = 2 5 y = 4 gOO = 2 10 y = 6 gOO = 1 2 y = 2 gOO = 4 7 y = 6 gOO = 1 6 y = 4 gOO = 4 10 y = 7 gOO = 6 8 y = 7 gOO = 5 10 y = 8 gOO = 5 10 y = 8 gOO = 7 8 y = 8 gOO = 4 8 y = 6 gOO = 5 8 y = 7 gOO = 1 10 y = 6 gOO = 8 10 y = 9 gOO = 1 2 y = 2 gOO = 1 7 y = 4 gOO = 5 10 y = 8 gOO = 3 4 y = 4 gOO = 5 10 y = 8 gOO = 5 8 y = 7 gOO = 2 9 y = 6 gOO = 1 8 y = 5 gOO = 4 8 y = 6 gOO = 7 8 y = 8 gOO = 3 10 y = 7 gOO = 4 5 y = 5 gOO = 1 2 y = 2 gOO = 5 8 y = 7 gOO = 1 2 y = 2 gOO = 5 8 y = 7 gOO = 8 9 y = 9 gOO = 5 8 y = 7 gOO = 4 9 y = 7 gOO = 2 8 y = 5 gOO = 6 7 y = 7 gOO = 3 7 y = 5 gOO = 3 7 y = 5 gOO = 4 9 y = 7 gOO = 1 2 y = 2 gOO = 5 8 y = 7 gOO = 3 5 y = 4 gOO = 4 6 y = 5 gOO = 3 10 y = 7 gOO = 1 5 y = 3 gOO = 1 7 y = 4 gOO = 7 8 y = 8 gOO = 2 4 y = 3 gOO = 3 9 y = 6 gOO = 9 10 y = 10 gOO = 5 7 y = 6 gOO = 6 8 y = 7 gOO = 1 2 y = 2 gOO = 4 5 y = 5 gOO = 2 8 y = 5 gOO = 5 10 y = 8 gOO = 1 8 y = 5 gOO = 5 6 y = 6 gOO = 8 10 y = 9 gOO = 5 8 y = 7 gOO = 1 8 y = 5 gOO = 2 6 y = 4 gOO = 3 6 y = 5 gOO = 3 5 y = 4 gOO = 1 3 y = 2 gOO = 1 5 y = 3 gOO = 9 10 y = 10 gOO = 3 9 y = 6 gOO = 2 8 y = 5 gOO = 4 10 y = 7 gOO = 1 2 y = 2 gOO = 2 8 y = 5 gOO = 5 10 y = 8 gOO = 4 6 y = 5 gOO = 8 10 y = 9 gOO = 4 5 y = 5 gOO = 2 10 y = 6 gOO = 4 7 y = 6 gOO = 9 10 y = 10 gOO = 6 7 y = 7 gOO = 1 3 y = 2 gOO = 1 6 y = 4 gOO = 6 10 y = 8 gOO = 4 6 y = 5 gOO = 1 4 y = 3 gOO = 1 9 y = 5 gOO = 4 5 y = 5 gOO = 3 8 y = 6 gOO = 7 8 y = 8 gOO = 1 4 y = 3 gOO = 2 7 y = 5 gOO = 4 10 y = 7 gOO = 2 4 y = 3 gOO = 4 10 y = 7 gOO = 2 5 y = 4 gOO = 4 7 y = 6 gOO = 1 10 y = 6 gOO = 2 5 y = 4 gOO = 5 8 y = 7 gOO = 6 7 y = 7 gOO = 6 10 y = 8 gOO = 7 10 y = 9 gOO = 3 6 y = 5 gOO = 1 2 y = 2 gOO = 3 9 y = 6 gOO = 1 8 y = 5 gOO = 2 6 y = 4 gOO = 1 7 y = 4 gOO = 2 4 y = 3 gOO = 6 8 y = 7 gOO = 8 9 y = 9 gOO = 1 5 y = 3 gOO = 1 3 y = 2 gOO = 4 6 y = 5 gOO = 4 10 y = 7 gOO = 8 10 y = 9 gOO = 1 4 y = 3 gOO = 2 4 y = 3 gOO = 1 3 y = 2 gOO = 6 7 y = 7 gOO = 4 9 y = 7 gOO = 3 10 y = 7 gOO = 3 4 y = 4 gOO = 7 8 y = 8 gOO = 4 9 y = 7 gOO = 2 8 y = 5 gOO = 7 9 y = 8 gOO = 2 3 y = 3 gOO = 1 5 y = 3 gOO = 3 6 y = 5 gOO = 1 10 y = 6 gOO = 1 7 y = 4 gOO = 1 4 y = 3 gOO = 5 9 y = 7 gOO = 2 5 y = 4 gOO = 4 5 y = 5 gOO = 2 10 y = 6 gOO = 4 5 y = 5 gOO = 4 9 y = 7 gOO = 6 8 y = 7 gOO = 3 7 y = 5 gOO = 8 10 y = 9 gOO = 6 7 y = 7 gOO = 8 9 y = 9 gOO = 3 4 y = 4 gOO = 9 10 y = 10 gOO = 8 9 y = 9 gOO = 7 8 y = 8 gOO = 4 5 y = 5 gOO = 1 7 y = 4 gOO = 7 10 y = 9 gOO = 2 3 y = 3 gOO = 2 4 y = 3 gOO = 1 5 y = 3 gOO = 7 10 y = 9 gOO = 2 4 y = 3 gOO = 6 9 y = 8 gOO = 1 9 y = 5 gOO = 2 3 y = 3 gOO = 6 7 y = 7 gOO = 4 6 y = 5 gOO = 3 10 y = 7 gOO = 1 7 y = 4 gOO = 6 8 y = 7 gOO = 1 3 y = 2 gOO = 1 9 y = 5 gOO = 4 5 y = 5 gOO = 2 8 y = 5 gOO = 7 8 y = 8 gOO = 5 10 y = 8 gOO = 2 8 y = 5 gOO = 2 10 y = 6 gOO = 2 9 y = 6 gOO = 2 8 y = 5 gOO = 1 4 y = 3 gOO = 6 9 y = 8 gOO = 2 9 y = 6 gOO = 8 10 y = 9 gOO = 3 9 y = 6 gOO = 3 6 y = 5 gOO = 5 8 y = 7 gOO = 1 8 y = 5 gOO = 2 8 y = ...

3   Fail
maxIts = 100000; tic for j = 1 : 10 WDL = [0 0 0]; for itn = 1 : maxIts numberToBeGuessed = randi(10); gOO = randperm(10, 2); diffs = abs( [gOO myGuess(gOO)] - numberToBeGuessed ); winningContestant = find( min(diffs)==diffs ); if any( winningContestant == 3 ), if length(winningContestant) == 1, % Win WDL(1) = WDL(1) + 1; else % Draw WDL(2) = WDL(2) + 1; end; else % Loss WDL(3) = WDL(3) + 1; end; end; successRate = (WDL(1) + WDL(2)/2) / maxIts assert( successRate >= 0.45 ) end; toc

gOO = 6 9 y = 8 gOO = 7 9 y = 8 gOO = 4 8 y = 6 gOO = 1 10 y = 6 gOO = 1 9 y = 5 gOO = 2 4 y = 3 gOO = 2 5 y = 4 gOO = 1 4 y = 3 gOO = 2 5 y = 4 gOO = 3 8 y = 6 gOO = 5 6 y = 6 gOO = 1 7 y = 4 gOO = 3 8 y = 6 gOO = 2 3 y = 3 gOO = 9 10 y = 10 gOO = 1 3 y = 2 gOO = 2 4 y = 3 gOO = 6 7 y = 7 gOO = 2 5 y = 4 gOO = 3 8 y = 6 gOO = 4 9 y = 7 gOO = 9 10 y = 10 gOO = 4 10 y = 7 gOO = 2 6 y = 4 gOO = 5 9 y = 7 gOO = 3 5 y = 4 gOO = 6 7 y = 7 gOO = 1 7 y = 4 gOO = 3 5 y = 4 gOO = 6 10 y = 8 gOO = 5 9 y = 7 gOO = 2 7 y = 5 gOO = 7 9 y = 8 gOO = 1 4 y = 3 gOO = 2 3 y = 3 gOO = 4 5 y = 5 gOO = 4 8 y = 6 gOO = 1 10 y = 6 gOO = 6 10 y = 8 gOO = 1 6 y = 4 gOO = 4 9 y = 7 gOO = 1 6 y = 4 gOO = 7 10 y = 9 gOO = 1 7 y = 4 gOO = 4 10 y = 7 gOO = 3 5 y = 4 gOO = 3 5 y = 4 gOO = 7 9 y = 8 gOO = 1 9 y = 5 gOO = 4 7 y = 6 gOO = 7 9 y = 8 gOO = 1 7 y = 4 gOO = 1 5 y = 3 gOO = 4 5 y = 5 gOO = 2 3 y = 3 gOO = 3 6 y = 5 gOO = 4 7 y = 6 gOO = 5 8 y = 7 gOO = 4 5 y = 5 gOO = 8 10 y = 9 gOO = 1 2 y = 2 gOO = 6 9 y = 8 gOO = 8 9 y = 9 gOO = 4 7 y = 6 gOO = 5 10 y = 8 gOO = 8 9 y = 9 gOO = 4 9 y = 7 gOO = 5 6 y = 6 gOO = 7 9 y = 8 gOO = 4 8 y = 6 gOO = 4 9 y = 7 gOO = 2 4 y = 3 gOO = 2 7 y = 5 gOO = 5 10 y = 8 gOO = 4 5 y = 5 gOO = 5 10 y = 8 gOO = 6 9 y = 8 gOO = 3 10 y = 7 gOO = 2 9 y = 6 gOO = 3 6 y = 5 gOO = 1 8 y = 5 gOO = 3 9 y = 6 gOO = 1 4 y = 3 gOO = 2 5 y = 4 gOO = 7 10 y = 9 gOO = 3 9 y = 6 gOO = 5 6 y = 6 gOO = 2 8 y = 5 gOO = 5 6 y = 6 gOO = 2 10 y = 6 gOO = 1 3 y = 2 gOO = 3 9 y = 6 gOO = 1 7 y = 4 gOO = 3 10 y = 7 gOO = 3 4 y = 4 gOO = 5 10 y = 8 gOO = 2 7 y = 5 gOO = 8 9 y = 9 gOO = 8 9 y = 9 gOO = 4 10 y = 7 gOO = 4 8 y = 6 gOO = 7 8 y = 8 gOO = 2 3 y = 3 gOO = 1 10 y = 6 gOO = 5 9 y = 7 gOO = 7 8 y = 8 gOO = 1 9 y = 5 gOO = 5 10 y = 8 gOO = 2 7 y = 5 gOO = 6 9 y = 8 gOO = 4 10 y = 7 gOO = 5 10 y = 8 gOO = 3 9 y = 6 gOO = 3 4 y = 4 gOO = 2 8 y = 5 gOO = 4 5 y = 5 gOO = 5 9 y = 7 gOO = 2 7 y = 5 gOO = 4 5 y = 5 gOO = 6 7 y = 7 gOO = 2 5 y = 4 gOO = 1 6 y = 4 gOO = 1 2 y = 2 gOO = 5 6 y = 6 gOO = 1 9 y = 5 gOO = 2 8 y = 5 gOO = 1 9 y = 5 gOO = 3 4 y = 4 gOO = 5 10 y = 8 gOO = 1 6 y = 4 gOO = 8 9 y = 9 gOO = 6 9 y = 8 gOO = 4 8 y = 6 gOO = 4 8 y = 6 gOO = 7 8 y = 8 gOO = 3 4 y = 4 gOO = 1 7 y = 4 gOO = 1 2 y = 2 gOO = 5 10 y = 8 gOO = 3 5 y = 4 gOO = 2 8 y = 5 gOO = 1 3 y = 2 gOO = 1 9 y = 5 gOO = 1 4 y = 3 gOO = 2 3 y = 3 gOO = 3 6 y = 5 gOO = 2 9 y = 6 gOO = 2 6 y = 4 gOO = 1 3 y = 2 gOO = 5 10 y = 8 gOO = 5 9 y = 7 gOO = 1 4 y = 3 gOO = 3 4 y = 4 gOO = 2 5 y = 4 gOO = 3 4 y = 4 gOO = 7 10 y = 9 gOO = 1 10 y = 6 gOO = 8 9 y = 9 gOO = 1 10 y = 6 gOO = 4 5 y = 5 gOO = 4 7 y = 6 gOO = 1 8 y = 5 gOO = 2 3 y = 3 gOO = 2 7 y = 5 gOO = 2 8 y = 5 gOO = 4 8 y = 6 gOO = 2 4 y = 3 gOO = 2 4 y = 3 gOO = 1 10 y = 6 gOO = 3 6 y = 5 gOO = 1 2 y = 2 gOO = 4 8 y = 6 gOO = 6 8 y = 7 gOO = 4 7 y = 6 gOO = 3 9 y = 6 gOO = 2 6 y = 4 gOO = 1 9 y = 5 gOO = 2 6 y = 4 gOO = 1 6 y = 4 gOO = 9 10 y = 10 gOO = 5 10 y = 8 gOO = 5 8 y = 7 gOO = 7 8 y = 8 gOO = 7 10 y = 9 gOO = 9 10 y = 10 gOO = 1 6 y = 4 gOO = 4 9 y = 7 gOO = 2 10 y = 6 gOO = 5 7 y = 6 gOO = 1 2 y = 2 gOO = 5 6 y = 6 gOO = 9 10 y = 10 gOO = 3 9 y = 6 gOO = 7 8 y = 8 gOO = 2 4 y = 3 gOO = 5 10 y = 8 gOO = 4 7 y = 6 gOO = 3 9 y = 6 gOO = 1 8 y = 5 gOO = 1 2 y = 2 gOO = 5 7 y = 6 gOO = 3 9 y = 6 gOO = 7 10 y = 9 gOO = 5 7 y = 6 gOO = 1 6 y = 4 gOO = 2 10 y = 6 gOO = 3 10 y = 7 gOO = 5 9 y = 7 gOO = 7 9 y = 8 gOO = 5 7 y = 6 gOO = 7 10 y = 9 gOO = 5 10 y = 8 gOO = 4 5 y = 5 gOO = 5 10 y = 8 gOO = 4 9 y = 7 gOO = 3 9 y = 6 gOO = 6 10 y = 8 gOO = 1 5 y = 3 gOO = 5 7 y = 6 gOO = 3 8 y = 6 gOO = 1 7 y = 4 gOO = 9 10 y = 10 gOO = 6 9 y = 8 gOO = 4 6 y = 5 gOO = 1 9 y = 5 gOO = 6 7 y = 7 gOO = 2 10 y = 6 gOO = 2 9 y = 6 gOO = 6 10 y = 8 gOO = 1 8 y = 5 gOO = 6 9 y = 8 gOO = 3 4 y = 4 gOO = 4 5 y = 5 gOO = 3 7 y = 5 gOO = 5 6 y = 6 gOO = 2 6 y = 4 gOO = 3 6 y = 5 gOO = 3 7 y = 5 gOO = 7 8 y = 8 gOO = 7 8 y = 8 gOO = 1 6 y = 4 gOO = 4 6 y = 5 gOO = 4 7 y = 6 gOO = 6 9 y = 8 gOO = 2 8 y = 5 gOO = 1 9 y = 5 gOO = 3 7 y = 5 gOO = 1 9 y = 5 gOO = 2 8 y = 5 gOO = 1 7 y = 4 gOO = 2 7 y = 5 gOO = 5 7 y = 6 gOO = 4 9 y = 7 gOO = 4 8 y = 6 gOO = 1 3 y = 2 gOO = 6 9 y = 8 gOO = 4 10 y = 7 gOO = 2 10 y = 6 gOO = 7 10 y = 9 gOO = 5 9 y = 7 gOO = 1 10 y = 6 gOO = 1 6 y = 4 gOO = 7 10 y = 9 gOO = 7 8 y = 8 gOO = 4 10 y = 7 gOO = 3 9 y = 6 gOO = 6 8 y = 7 gOO = 5 8 y = 7 gOO = 1 10 y = 6 gOO = 6 9 y = 8 gOO = 4 7 y = 6 gOO = 8 10 y = 9 gOO = 2 7 y = 5 gOO = 4 10 y = 7 gOO = 4 7 y = 6 gOO = 8 10 y = 9 gOO = 2 3 y = 3 gOO = 5 8 y = ...

Assertion failed.