Cody

Problem 42705. Is It a Snake?

Solution 2104731

Submitted on 24 Jan 2020 by Adam
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 tf = logical 1 x1 = 1 y1 = 2 x2 = 1 y2 = 1 tf = logical 1 x1 = 1 y1 = 1 x2 = 1 y2 = 3 tf = logical 0 x1 = 1 y1 = 3 x2 = 1 y2 = 4 tf = logical 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 tf = logical 1 x1 = 1 y1 = 2 x2 = 1 y2 = 3 tf = logical 1 x1 = 1 y1 = 3 x2 = 2 y2 = 3 tf = logical 1 x1 = 2 y1 = 3 x2 = 2 y2 = 2 tf = logical 1 x1 = 2 y1 = 2 x2 = 2 y2 = 1 tf = logical 1 x1 = 2 y1 = 1 x2 = 1 y2 = 1 tf = logical 1

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

a = 1 2 3 4 tf = logical 1 x1 = 1 y1 = 1 x2 = 1 y2 = 2 tf = logical 1 x1 = 1 y1 = 2 x2 = 2 y2 = 1 tf = logical 0 x1 = 2 y1 = 1 x2 = 2 y2 = 2 tf = logical 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 tf = logical 1 x1 = 2 y1 = 2 x2 = 2 y2 = 3 tf = logical 1 x1 = 2 y1 = 3 x2 = 3 y2 = 3 tf = logical 1 x1 = 3 y1 = 3 x2 = 3 y2 = 2 tf = logical 1 x1 = 3 y1 = 2 x2 = 3 y2 = 1 tf = logical 1 x1 = 3 y1 = 1 x2 = 2 y2 = 1 tf = logical 1 x1 = 2 y1 = 1 x2 = 1 y2 = 1 tf = logical 1 x1 = 1 y1 = 1 x2 = 1 y2 = 2 tf = logical 1 x1 = 1 y1 = 2 x2 = 1 y2 = 3 tf = logical 1 x1 = 1 y1 = 3 x2 = 1 y2 = 4 tf = logical 1 x1 = 1 y1 = 4 x2 = 2 y2 = 4 tf = logical 1 x1 = 2 y1 = 4 x2 = 3 y2 = 4 tf = logical 1 x1 = 3 y1 = 4 x2 = 4 y2 = 4 tf = logical 1 x1 = 4 y1 = 4 x2 = 4 y2 = 3 tf = logical 1 x1 = 4 y1 = 3 x2 = 4 y2 = 2 tf = logical 1 x1 = 4 y1 = 2 x2 = 4 y2 = 1 tf = logical 1

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

a = 1 2 3 2 1 tf = logical 0

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

a = 6 5 4 3 tf = logical 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 tf = logical 1 x1 = 1 y1 = 1 x2 = 1 y2 = 2 tf = logical 1 x1 = 1 y1 = 2 x2 = 1 y2 = 3 tf = logical 1 x1 = 1 y1 = 3 x2 = 2 y2 = 1 tf = logical 0 x1 = 2 y1 = 1 x2 = 2 y2 = 2 tf = logical 0 x1 = 2 y1 = 2 x2 = 2 y2 = 3 tf = logical 0 x1 = 2 y1 = 3 x2 = 3 y2 = 1 tf = logical 0 x1 = 3 y1 = 1 x2 = 3 y2 = 2 tf = logical 0 x1 = 3 y1 = 2 x2 = 3 y2 = 3 tf = logical 0

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

tf = logical 0

Suggested Problems

More from this Author50