Cody

Solution 1691701

Submitted on 13 Dec 2018
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)) )

win = 1 win = 0 win = 0.9986 win = 0.0014 win = 0.9782 win = 0.0218 win = 0.9008 win = 0.0992 win = 0.7357 win = 0.2643 win = 0.5000 win = 0.5000

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

win = 0.5000

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

win = 0

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

win = 1

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

win = 9.2327e-05

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

win = 0.0014

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

win = 0.0071

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

win = 0.0218

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

win = 0.0508

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

win = 0.0992

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

win = 0.1704

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

win = 0.2643

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

win = 0.3769

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

win = 0.4750

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

win = 0.1874

Assertion failed.