Cody

Problem 44630. Guess the number I'm thinking of

Solution 3377023

Submitted on 25 Oct 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;

a = 1 b = 2 ans = 3 a = 3 b = 6 ans = 7 a = 4 b = 7 ans = 8 a = 1 b = 4 ans = 5 a = 2 b = 4 ans = 5 a = 2 b = 9 ans = 5.5000 a = 1 b = 8 ans = 4.5000 a = 4 b = 9 ans = 3 a = 5 b = 9 ans = 10 a = 4 b = 5 ans = 6 a = 8 b = 9 ans = 10 a = 6 b = 8 ans = 9 a = 4 b = 8 ans = 9 a = 1 b = 4 ans = 5 a = 6 b = 7 ans = 8 a = 5 b = 8 ans = 9 a = 3 b = 10 ans = 6.5000 a = 5 b = 6 ans = 7 a = 2 b = 4 ans = 5 a = 5 b = 7 ans = 8 a = 5 b = 10 ans = 4 a = 1 b = 7 ans = 8 a = 7 b = 9 ans = 10 a = 6 b = 10 ans = 5 a = 5 b = 8 ans = 9 a = 2 b = 6 ans = 7 a = 5 b = 9 ans = 10 a = 2 b = 8 ans = 9 a = 1 b = 7 ans = 8 a = 4 b = 8 ans = 9 a = 7 b = 10 ans = 6 a = 2 b = 5 ans = 6 a = 7 b = 9 ans = 10 a = 2 b = 5 ans = 6 a = 5 b = 7 ans = 8 a = 1 b = 6 ans = 7 a = 6 b = 8 ans = 9 a = 2 b = 5 ans = 6 a = 7 b = 10 ans = 6 a = 1 b = 6 ans = 7 a = 3 b = 8 ans = 9 a = 4 b = 8 ans = 9 a = 5 b = 8 ans = 9 a = 1 b = 4 ans = 5 a = 2 b = 3 ans = 4 a = 3 b = 4 ans = 5 a = 4 b = 6 ans = 7 a = 2 b = 6 ans = 7 a = 4 b = 9 ans = 3 a = 1 b = 3 ans = 4 a = 1 b = 6 ans = 7 a = 4 b = 6 ans = 7 a = 6 b = 9 ans = 10 a = 4 b = 7 ans = 8 a = 5 b = 8 ans = 9 a = 9 b = 10 ans = 11

Out of requested range.

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

a = 1 b = 4 ans = 5 a = 5 b = 7 ans = 8 a = 5 b = 7 ans = 8 a = 4 b = 10 ans = 3 a = 1 b = 10 ans = 5.5000 a = 2 b = 10 ans = 6 a = 5 b = 10 ans = 4 a = 1 b = 10 ans = 5.5000 a = 9 b = 10 ans = 11 a = 2 b = 3 ans = 4 a = 2 b = 9 ans = 5.5000 a = 9 b = 10 ans = 11 a = 8 b = 10 ans = 11 a = 4 b = 9 ans = 3 a = 2 b = 6 ans = 7 a = 2 b = 6 ans = 7 a = 1 b = 9 ans = 5 a = 3 b = 6 ans = 7 a = 3 b = 8 ans = 9 a = 3 b = 4 ans = 5 a = 2 b = 3 ans = 4 a = 1 b = 5 ans = 6 a = 3 b = 4 ans = 5 a = 5 b = 10 ans = 4 a = 2 b = 10 ans = 6 a = 5 b = 10 ans = 4 a = 1 b = 7 ans = 8 a = 2 b = 6 ans = 7 a = 1 b = 2 ans = 3 a = 6 b = 9 ans = 10 a = 6 b = 8 ans = 9 a = 2 b = 4 ans = 5 a = 3 b = 9 ans = 2 a = 5 b = 6 ans = 7 a = 3 b = 4 ans = 5 a = 5 b = 10 ans = 4 a = 3 b = 5 ans = 6 a = 5 b = 7 ans = 8 a = 5 b = 10 ans = 4 a = 4 b = 10 ans = 3 a = 3 b = 8 ans = 9 a = 8 b = 10 ans = 11 a = 8 b = 10 ans = 11 a = 7 b = 10 ans = 6 a = 4 b = 8 ans = 9 a = 4 b = 10 ans = 3 a = 3 b = 9 ans = 2 a = 1 b = 7 ans = 8 a = 4 b = 5 ans = 6 a = 6 b = 8 ans = 9 a = 2 b = 6 ans = 7 a = 4 b = 6 ans = 7 a = 2 b = 9 ans = 5.5000 a = 7 b = 9 ans = 10 a = 5 b = 6 ans = 7 a = 4 b = 5 ans = 6 a = 5 b = 8 ans = 9 a = 4 b = 9 ans = 3 a = 1 b = 2 ans = 3 a = 2 b = 3 ans = 4 a = 2 b = 5 ans = 6 a = 7 b = 8 ans = 9 a = 3 b = 4 ans = 5 a = 2 b = 8 ans = 9 a = 8 b = 10 ans = 11 a = 1 b = 9 ans = 5 a = 4 b = 8 ans = 9 a = 1 b = 6 ans = 7 a = 6 b = 7 ans = 8 a = 4 b = 10 ans = 3 a = 5 b = 7 ans = 8 a = 1 b = 2 ans = 3 a = 1 b = 2 ans = 3 a = 1 b = 3 ans = 4 a = 4 b = 7 ans = 8 a = 6 b = 8 ans = 9 a = 1 b = 6 ans = 7 a = 4 b = 10 ans = 3 a = 1 b = 7 ans = 8 a = 1 b = 8 ans = 4.5000 a = 4 b = 9 ans = 3 a = 6 b = 8 ans = 9 a = 2 b = 4 ans = 5 a = 1 b = 3 ans = 4 a = 6 b = 7 ans = 8 a = 3 b = 9 ans = 2 a = 1 b = 8 ans = 4.5000 a = 3 b = 9 ans = 2 a = 3 b = 5 ans = 6 a = 4 b = 8 ans = 9 a = 4 b = 10 ans = 3 a = 1 b = 6 ans = 7 a = 2 b = 10 ans = 6 a = 1 b = 4 ans = 5 a = 2 b = 10 ans = 6 a = 1 b = 8 ans = 4.5000 a = 4 b = 10 ans = 3 a = 5 b = 10 ans = 4 a = 1 b = 10 ans = 5.5000 a = 9 b = 10 ans = 11 a = 5 b = 6 ans = 7 a = 4 b = 10 ans = 3 a = 5 b = 8 ans = 9 a = 4 b = 7 ans = 8 a = 2 b = 10 ans = 6 a = 5 b = 9 ans = 10 a = 1 b = 8 ans = 4.5000 a = 2 b = 3 ans = 4 a = 5 b = 7 ans = 8 a = 4 b = 6 ans = 7 a = 1 b = 2 ans = 3 a = 8 b = 9 ans = 10 a = 2 b = 6 ans = 7 a = 3 b = 5 ans = 6 a = 3 b = 4 ans = 5 a = 3 b = 10 ans = 6.5000 a = 1 b = 4 ans = 5 a = 1 b = 6 ans = 7 a = 2 b = 5 ans = 6 a = 1 b = 2 ans = 3 a = 4 b = 9 ans = 3 a = 6 b = 9 ans = 10 a = 1 b = 3 ans = 4 a = 1 b = 10 ans = 5.5000 a = 5 b = 10 ans = 4 a = 4 b = 10 ans = 3 a = 5 b = 8 ans = 9 a = 3 b = 7 ans = 8 a = 1 b = 2 ans = 3 a = 2 b = 6 ans = 7 a = 5 b = 8 ans = 9 a = 4 b = 8 ans = 9 a = 2 b = 5 ans = 6 a = 5 b = 10 ans = 4 a = 6 b = 7 ans = 8 a = 9 b = 10 ans = 11 a = 8 b = 9 ans = 10 a = 3 b = 4 ans = 5 a = 1 b = 6 ans = 7 a = 9 b = 10 ans = 11 a = 3 b = 10 ans = 6.5000 a = 2 b = 8 ans = 9 a = 5 b = 9 ans = 10 a = 4 b = 10 ans = 3 a = 2 b = 3 ans = 4 a = 4 b = 6 ans = 7 a = 1 b = 6 ans = 7 a = 1 b = 7 ans = 8 a = 2 b = 4 ans = 5 a = 2 b = 5 ans = 6 a = 2 b = 3 ans = 4 a = 1 b = 3 ans = 4 a = 2 b = 5 ans = 6 a = 1 b = 5 ans = 6 a = 4 b = 8 ans = 9 a = 1 b = 10 ans = 5.5000 a = 8 b = 10 ans = 11 a = 1 b = 6 ans = 7 a = 7 b = 9 ans = 10 a = 4 b = 6 ans = 7 a = 5 b = 9 ans = 10 a = 5 b = 6 ans = 7 a = 4 b = 10 ans = 3 a = 1 b = 4 ans = 5 a = 5 b = 9 ans = 10 a = 4 b = 6 ans = 7 a = 1 b = 4 ans = 5 a = 4 b = 9 ans = 3 a = 1 b = 10 ans = 5.5000 a = 5 b = 10 ans = 4 a = 6 b = 7 ans = 8 a = 6 b = 8 ans = 9 a = 3 b = 4 ans = 5 a = 2 b = 5 ans = 6 a = 7 b = 8 ans = 9 a = 4 b = 10 ans = 3 a = 1 b = 10 ans = 5.5000 a = 3 b = 8 ans = 9 a = 1 b = 8 ans = 4.5000 a = 1 b = 5 ans = 6 a = 5 b = 8 ans = 9 a = 3 b = 7 ans = 8 a = 5 b = 8 ans = 9 a = 2 b = 7 ans = 8 a = 2 b = 8 ans = 9 a = 2 b = 9 ans = 5.5000 a = 5 b = 7 ans = 8 a = 4 b = 8 ans = 9 a = 2 b = 4 ans = 5 a = 3 b = 5 ans = 6 a = 5 b = 6 ans = 7 a = 3 b = 5 ans = 6 a = 5 b = 10 ans = 4 a = 1 b = 3 ans = 4 a = 6 b = 9 ans = 10 a = 4 b = 6 ans = 7 a = 1 b = 6 ans = 7 a = 1 b = 9 ans = 5 a = 7 b = 9 ans = 10 a = 1 b = 5 ans = 6 a = 3 b = 9 ans = 2 a = 5 b = 8 ans = 9 a = 4 b = 10 ans = 3 a = 3 b = 4 ans = 5 a = 5 b = 6 ans = 7 a = 5 b = 10 ans = 4 a = 2 b = 6 ans = 7 a = 6 b = 7 ans = 8 a = 9 b = 10 ans = 11 a = 7 b = 8 ans = 9 a = 7 b = 10 ans = 6 a = 5 b = 9 ans = 10 a = 5 b = 9 ans = 10 a = 6 b = 7 ans = 8 a = 3 b = 4 ans = 5 a = 1 b = 2 ans = 3 a = 4 b = 7 ans = 8 a = 9 b = 10 ans = 11 a = 4 b = 6 ans = 7 a = 9 b = 10 ans = 11 a = 4 b = 9 ans = 3 a = 5 b = 7 ans = 8 a = 2 b = 6 ans = 7 a = 3 b = 8 ans = 9 a = 6 b = 9 ans = 10 a = 1 b = 7 ans ...

Assertion failed.

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!