Cody

Problem 46037. Count alternating permutations

Solution 2676365

Submitted on 10 Jul 2020 by Tim
  • Size: 28
  • 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 = 1; y_correct = 1; assert(isequal(altperm(n),y_correct))

2   Pass
n = 3; y_correct = 2; assert(isequal(altperm(n),y_correct))

3   Pass
n = 4; y_correct = 5; assert(isequal(altperm(n),y_correct))

4   Pass
n = 6; y_correct = 61; assert(isequal(altperm(n),y_correct))

5   Pass
n = 8; y_correct = 1385; assert(isequal(altperm(n),y_correct))

6   Pass
n = 11; y_correct = 353792; assert(isequal(altperm(n),y_correct))

7   Pass
n = 13; y_correct = 22368256; assert(isequal(altperm(n),y_correct))

8   Pass
n = 5; y_correct = 19391512145; assert(isequal(altperm(altperm(n)),y_correct))