Cody

Problem 46551. Solve a ballot counting problem

Solution 2873162

Submitted on 24 Aug 2020 by James
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
n = 3; y_correct = 5; assert(isequal(ballot1(n),y_correct))

y = 5

2   Pass
n = 6; y_correct = 132; assert(isequal(ballot1(n),y_correct))

y = 132

3   Pass
n = 9; y_correct = 4862; assert(isequal(ballot1(n),y_correct))

y = 4862

4   Pass
n1 = 11; n2 = 13; y1 = ballot1(n1); y2 = ballot1(n2); sum_correct = 801686; mod_correct = 37468; assert(isequal(y1+y2,sum_correct) && isequal(mod(y2,y1),mod_correct))

y = 58786 y = 742900

5   Pass
n = 22; y_correct = 91482563640; assert(isequal(ballot1(n),y_correct))

y = 9.1483e+10

6   Pass
n = 26; y_correct = 18367353072152; assert(isequal(ballot1(n),y_correct))

y = 1.8367e+13