Cody

Problem 46582. Find jumping medalists

Solution 2938669

Submitted on 11 Sep 2020 by William
  • Size: 145
  • This is the leading solution.
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 = 2; [J1,J2,J3,Jmax] = jumpingMedalists(n); assert(isempty(J1) && isempty(J2) && isempty(J3) && isempty(Jmax))

2   Pass
n = 5; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = [1 2]; Jmax_correct = 2; assert(isequal(J1,J1_correct) && isempty(J2) && isempty(J3) && isequal(Jmax,Jmax_correct))

3   Pass
n = 7; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 2; J2_correct = 1; Jmax_correct = 2; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isempty(J3) && isequal(Jmax,Jmax_correct))

4   Pass
n = 11; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 2; J2_correct = [1 4]; Jmax_correct = 4; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isempty(J3) && isequal(Jmax,Jmax_correct))

5   Pass
n = 20; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 2; J2_correct = 4; J3_correct = 1; Jmax_correct = 4; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

6   Pass
n = 100; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 2; J2_correct = [4 6]; Jmax_correct = 8; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isempty(J3) && isequal(Jmax,Jmax_correct))

7   Pass
n = 3141; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 6; J2_correct = 4; J3_correct = 2; Jmax_correct = 34; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

8   Pass
n = 50011; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 6; J2_correct = 2; J3_correct = 4; Jmax_correct = 72; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

9   Pass
n = 6021023; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 6; J2_correct = 12; J3_correct = 2; Jmax_correct = 154; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

10   Pass
n = 12221997; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 6; J2_correct = 12; J3_correct = 2; Jmax_correct = 154; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

11   Pass
n = 2e8; [J1,J2,J3,Jmax] = jumpingMedalists(n); J1_correct = 6; J2_correct = 12; J3_correct = 4; Jmax_correct = 248; assert(isequal(J1,J1_correct) && isequal(J2,J2_correct) && isequal(J3,J3_correct) && isequal(Jmax,Jmax_correct))

Suggested Problems

More from this Author47

Community Treasure Hunt

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

Start Hunting!