Cody

# Problem 1482. Number of cyles and fixed points in a permutation

Solution 722117

Submitted on 25 Aug 2015 by kfncgnhx eprueqxc
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
%% x = [3 4 5 7 6 1 8 2]; y_correct = 2; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = Empty matrix: 1-by-0

2   Pass
%% x = [2 3 4 1 5 6]; y_correct = 3; assert(isequal(number_of_cycles(x),y_correct))

i_p = 5 i_p = 6 i_p = Empty matrix: 1-by-0

3   Pass
%% x = [1]; y_correct = 1; assert(isequal(number_of_cycles(x),y_correct))

i_p = []

4   Pass
%% x = [1 2]; y_correct = 2; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = Empty matrix: 1-by-0

5   Pass
%% x = [2 1]; y_correct = 1; assert(isequal(number_of_cycles(x),y_correct))

i_p = Empty matrix: 1-by-0

6   Pass
%% x = [4 5 7 6 8 2 1 3]; y_correct = 1; assert(isequal(number_of_cycles(x),y_correct))

i_p = Empty matrix: 1-by-0

7   Pass
%% x = [4 2 7 6 5 8 1 3]; y_correct = 3; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = 5 i_p = Empty matrix: 1-by-0

8   Pass
%% x = [3 4 1 2 6 5]; y_correct = 3; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = 5 i_p = Empty matrix: 1-by-0

9   Pass
%% x = [3 4 1 2 6 5 8 9 7]; y_correct = 4; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = 5 i_p = 7 i_p = Empty matrix: 1-by-0

10   Pass
%% x = [3 4 1 2 6 5 8 9 7 10]; y_correct = 5; assert(isequal(number_of_cycles(x),y_correct))

i_p = 2 i_p = 5 i_p = 7 i_p = 10 i_p = Empty matrix: 1-by-0

11   Pass
%% x = [3 4 2 5 1 8 9 7 10 6]; y_correct = 2; assert(isequal(number_of_cycles(x),y_correct))

i_p = 6 i_p = Empty matrix: 1-by-0

12   Pass
%% x = [3 4 2 5 1 8 9 7 10 6 11]; y_correct = 3; assert(isequal(number_of_cycles(x),y_correct))

i_p = 6 i_p = 11 i_p = Empty matrix: 1-by-0