Cody

Solution 1805413

Submitted on 4 May 2019 by William
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
% The Test Suite will be updated if inappropriate submissions are received. % This includes hard-coded (pre-calculated, externally calculated, manually calculated) 'solutions'. filetext = fileread('standardGame.m'); vec = [923273, 144780, 713710, 217788, 507812, 992110, 170355, 264270, 376851, 475014]; msg = 'Please do not hard-code your ''solution''.'; assert( all( arrayfun(@(z) isempty(strfind(filetext, num2str(z))), vec) ) , msg )

2   Pass
% There are only two players, so the chances for each should add up to one. assert( abs(standardGame(100)+standardGame(0) - 1) < 20 * eps(single(1)) ) assert( abs(standardGame(90)+standardGame(10) - 1) < 20 * eps(single(1)) ) assert( abs(standardGame(80)+standardGame(20) - 1) < 20 * eps(single(1)) ) assert( abs(standardGame(70)+standardGame(30) - 1) < 20 * eps(single(1)) ) assert( abs(standardGame(60)+standardGame(40) - 1) < 20 * eps(single(1)) ) assert( abs(standardGame(50)+standardGame(50) - 1) < 20 * eps(single(1)) )

3   Pass
x = uint8(50); y_correct = 0.50; assert( isequal(standardGame(x), y_correct) )

4   Pass
x = uint8(0); y_correct = 0; assert( isequal(standardGame(x), y_correct) )

5   Pass
x = uint8(100); y_correct = 1; assert( isequal(standardGame(x), y_correct) )

6   Pass
x = uint8(5); y_correct = 0.0000923273480663; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

7   Pass
x = uint8(10); y_correct = 0.0014478048780488; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

8   Pass
x = uint8(15); y_correct = 0.0071371057046980; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

9   Pass
x = uint8(20); y_correct = 0.0217788235294118; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

10   Pass
x = uint8(25); y_correct = 0.0507812500000000; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

11   Pass
x = uint8(30); y_correct = 0.0992110344827586; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

12   Pass
x = uint8(35); y_correct = 0.1703553555045871; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

13   Pass
x = uint8(40); y_correct = 0.2642707692307693; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

14   Pass
x = uint8(45); y_correct = 0.3768514975247527; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

15   Pass
x = uint8(49); y_correct = 0.4750149924031987; assert( abs( standardGame(x) - y_correct ) < 10 * eps(single(y_correct)) )

16   Pass
for i = 1:5 x = uint8( randi(100) ); assert( isequal(class(standardGame(x)), 'single') ) end;

Suggested Problems