Cody

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

Solution 2778547

Submitted on 4 Aug 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   Fail
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;

closestOppGuessDist = 4 myGuessDist = 0

Unrecognized function or variable 'expectedScore'. Error in myGuess (line 10) expectedScore(guess) = expectedScore + 1; Error in Test2 (line 4) mG = myGuess(gOO);

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

closestOppGuessDist = 0 myGuessDist = 0

Unrecognized function or variable 'expectedScore'. Error in myGuess (line 8) expectedScores(guess) = expectedScore + 0.5; Error in Test3 (line 8) diffs = abs( [gOO myGuess(gOO)] - numberToBeGuessed );