Cody

# Problem 42705. Is It a Snake?

Solution 2062950

Submitted on 19 Dec 2019 by Asif Newaz
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
a = [ 2 1 3 4 ] tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

a = 2 1 3 4 m = 4 x = 2 y = 1 rx = 1 cx = 2 ry = 1 cy = 1 d = 1 tf = 1 x = 1 y = 3 rx = 1 cx = 1 ry = 1 cy = 3 d = 2 tf = 0

2   Pass
a = [ 6 1 2 5 4 3 ] tf_correct = true; assert(isequal(isItSnaky(a),tf_correct))

a = 6 1 2 5 4 3 m = 6 x = 3 y = 5 rx = 1 cx = 2 ry = 1 cy = 3 d = 1 tf = 1 x = 5 y = 6 rx = 1 cx = 3 ry = 2 cy = 3 d = 1 tf = 1 x = 6 y = 4 rx = 2 cx = 3 ry = 2 cy = 2 d = 1 tf = 1 x = 4 y = 2 rx = 2 cx = 2 ry = 2 cy = 1 d = 1 tf = 1 x = 2 y = 1 rx = 2 cx = 1 ry = 1 cy = 1 d = 1 tf = 1

3   Pass
a = [ 1 2 3 4 ] tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

a = 1 2 3 4 m = 4 x = 1 y = 3 rx = 1 cx = 1 ry = 1 cy = 2 d = 1 tf = 1 x = 3 y = 2 rx = 1 cx = 2 ry = 2 cy = 1 d = 2 tf = 0

4   Pass
a = [ 7 8 9 10 6 1 2 11 5 4 3 12 16 15 14 13 ] tf_correct = true; assert(isequal(isItSnaky(a),tf_correct))

a = 7 8 9 10 6 1 2 11 5 4 3 12 16 15 14 13 m = 16 x = 6 y = 10 rx = 2 cx = 2 ry = 2 cy = 3 d = 1 tf = 1 x = 10 y = 11 rx = 2 cx = 3 ry = 3 cy = 3 d = 1 tf = 1 x = 11 y = 7 rx = 3 cx = 3 ry = 3 cy = 2 d = 1 tf = 1 x = 7 y = 3 rx = 3 cx = 2 ry = 3 cy = 1 d = 1 tf = 1 x = 3 y = 2 rx = 3 cx = 1 ry = 2 cy = 1 d = 1 tf = 1 x = 2 y = 1 rx = 2 cx = 1 ry = 1 cy = 1 d = 1 tf = 1 x = 1 y = 5 rx = 1 cx = 1 ry = 1 cy = 2 d = 1 tf = 1 x = 5 y = 9 rx = 1 cx = 2 ry = 1 cy = 3 d = 1 tf = 1 x = 9 y = 13 rx = 1 cx = 3 ry = 1 cy = 4 d = 1 tf = 1 x = 13 y = 14 rx = 1 cx = 4 ry = 2 cy = 4 d = 1 tf = 1 x = 14 y = 15 rx = 2 cx = 4 ry = 3 cy = 4 d = 1 tf = 1 x = 15 y = 16 rx = 3 cx = 4 ry = 4 cy = 4 d = 1 tf = 1 x = 16 y = 12 rx = 4 cx = 4 ry = 4 cy = 3 d = 1 tf = 1 x = 12 y = 8 rx = 4 cx = 3 ry = 4 cy = 2 d = 1 tf = 1 x = 8 y = 4 rx = 4 cx = 2 ry = 4 cy = 1 d = 1 tf = 1

5   Pass
a = [ 1 2 3 2 1 ] tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

a = 1 2 3 2 1 m = 3 x = 1 5 y = 2 4 rx = 1 1 cx = 1 5 ry = 1 1 cy = 2 4 tf = 0

6   Pass
a = [ 6 5 4 3 ] tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

a = 6 5 4 3 m = 6 x = 1×0 empty double row vector y = 1×0 empty double row vector rx = 1×0 empty double row vector cx = 1×0 empty double row vector ry = 1×0 empty double row vector cy = 1×0 empty double row vector tf = 0

7   Pass
a = [ 1 2 3 4 5 6 7 8 9 ] tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

a = 1 2 3 4 5 6 7 8 9 m = 9 x = 1 y = 4 rx = 1 cx = 1 ry = 1 cy = 2 d = 1 tf = 1 x = 4 y = 7 rx = 1 cx = 2 ry = 1 cy = 3 d = 1 tf = 1 x = 7 y = 2 rx = 1 cx = 3 ry = 2 cy = 1 d = 3 tf = 0

8   Pass
a = [ 2 1 1 1 ]; tf_correct = false; assert(isequal(isItSnaky(a),tf_correct))

m = 2 x = 2 3 4 y = 1 rx = 1 1 1 cx = 2 3 4 ry = 1 cy = 1 tf = 0