Cody

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

Solution 1961348

Submitted on 6 Oct 2019 by Augusto Mazzei
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))

cycle = 1 cycle = 2

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

cycle = 1 cycle = 2 cycle = 3

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

cycle = 1

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

cycle = 1 cycle = 2

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

cycle = 1

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

cycle = 1

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

cycle = 1 cycle = 2 cycle = 3

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

cycle = 1 cycle = 2 cycle = 3

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

cycle = 1 cycle = 2 cycle = 3 cycle = 4

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

cycle = 1 cycle = 2 cycle = 3 cycle = 4 cycle = 5

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

cycle = 1 cycle = 2

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))

cycle = 1 cycle = 2 cycle = 3

### Community Treasure Hunt

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

Start Hunting!