Cody

Problem 46037. Count alternating permutations

Solution 2997616

Submitted on 27 Sep 2020 by ChrisR
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))

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!