Cody

# Problem 1268. Penny flipping - calculate winning probability (easy)

Solution 2944312

Submitted on 13 Sep 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
m = 1; n = 1; y_correct = 0.50; assert(isequal(penny_flip(m, n),y_correct))

y = 0.5000

2   Fail
m = 2; n = 2; y_correct = 0.50; assert(isequal(penny_flip(m, n),y_correct))

y = 0.2500

Assertion failed.

3   Fail
m = 1e6; n = 1e6; y_correct = 0.50; assert(isequal(penny_flip(m, n),y_correct))

y = 5.0000e-07

Assertion failed.

4   Fail
m = 4; n = 2; y_correct = 2/3; assert(abs(penny_flip(m, n)-y_correct) <= 0.01)

y = 0.1667

Assertion failed.

5   Fail
m = 2; n = 4; y_correct = 1/3; assert(abs(penny_flip(m, n)-y_correct) <= 0.01)

y = 0.1667

Assertion failed.

6   Fail
m = 106; n = 47; y_correct = 0.6928; assert(abs(penny_flip(m, n)-y_correct) <= 0.01)

y = 0.0065

Assertion failed.

7   Fail
m = 3; n = 4; y_correct = 0.4286; assert(abs(penny_flip(m, n)-y_correct) <= 0.01)

y = 0.1429

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!