Cody

Problem 2562. Juggling

Solution 2689184

Submitted on 13 Jul 2020 by Rafael S.T. Vieira
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
pattern = 1; y_correct = 1; assert(isequaln(siteswap(pattern),y_correct))

1

2   Pass
pattern = 2; y_correct = 2; assert(isequaln(siteswap(pattern),y_correct))

2

3   Pass
pattern = 3; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

3

4   Pass
pattern = [3 3]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

3 4

5   Pass
pattern = [5 5 1]; y_correct = NaN; assert(isequaln(siteswap(pattern),y_correct))

5 6 3

6   Pass
pattern = [5 5 2]; y_correct = 4; assert(isequaln(siteswap(pattern),y_correct))

5 6 4

7   Pass
pattern = [3 2 1]; y_correct = NaN; assert(isequaln(siteswap(pattern),y_correct))

3 3 3

8   Pass
pattern = [3 1 2]; y_correct = 2; assert(isequaln(siteswap(pattern),y_correct))

3 2 4

9   Pass
pattern = [4 4 1]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

4 5 3

10   Pass
pattern = [5 2 1]; y_correct = NaN; assert(isequaln(siteswap(pattern),y_correct))

5 3 3

11   Pass
pattern = [5 5 5 0 0]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

5 6 7 3 4

12   Pass
pattern = [5 3 1]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

5 4 3

13   Pass
pattern = [6 4 5 1]; y_correct = 4; assert(isequaln(siteswap(pattern),y_correct))

6 5 7 4

14   Pass
pattern = [7 3 3 3]; y_correct = 4; assert(isequaln(siteswap(pattern),y_correct))

7 4 5 6

15   Pass
pattern = [7 1]; y_correct = 4; assert(isequaln(siteswap(pattern),y_correct))

7 2

16   Pass
pattern = [5 3 1 4 5 3 0 5 5 2 0]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

5 4 3 7 9 8 6 12 13 11 10

17   Pass
pattern = [3 4 2]; y_correct = 3; assert(isequaln(siteswap(pattern),y_correct))

3 5 4

18   Pass
pattern = [7 7 1]; y_correct = 5; assert(isequaln(siteswap(pattern),y_correct))

7 8 3

19   Pass
pattern = [1 4 0 3]; y_correct = NaN; assert(isequaln(siteswap(pattern),y_correct))

1 5 2 6

20   Pass
pattern = [1 3 0 4]; y_correct = 2; assert(isequaln(siteswap(pattern),y_correct))

1 4 2 7

21   Pass
a=randi(100) pattern = [4*a, 0, 4*a-1, 1]; y_correct = NaN; assert(isequaln(siteswap(pattern),y_correct))

a = 58 232 1 233 4

22   Pass
a=randi(100) pattern = [4*a, 0, 1, 4*a-1]; y_correct = 2*a; assert(isequaln(siteswap(pattern),y_correct))

a = 73 292 1 3 294

23   Pass
assert(isequaln(siteswap([6 0 1 5]),siteswap([6 0 5 1])))

6 1 3 8 6 1 7 4

Suggested Problems

More from this Author41

Community Treasure Hunt

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

Start Hunting!