Cody

# Problem 194. Clockwise or Counterclockwise

Solution 1936106

Submitted on 14 Sep 2019 by nachi
• Size: 8
• This is the leading solution.
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 = [-1,-1,1,1]; y = [-1,1,1,-1]; d_correct = true; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
x = [-1,-1,-2,-2]; y = [-1,1,1,-1]; d_correct = false; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
x = [-1,-1,-2,-2]; y = [-1,1,1,-1]; d_correct = false; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
x = [-6,-7,-2,1,1,-2]; y = [4,-7,-13,-11,0,5]; d_correct = false; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
x = [-59,-59,-55,-51,-50,-46,-45,-45,-39,-40,-40,-41,-46,-50,-50]; y = [-68,-33, -5,-13,-28,-30,-20,-10, -8,-23,-34,-45,-48,-51,-51]; d_correct = true; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
x = flip([-59,-59,-55,-51,-50,-46,-45,-45,-39,-40,-40,-41,-46,-50,-50]); y = flip([-68,-33, -5,-13,-28,-30,-20,-10, -8,-23,-34,-45,-48,-51,-51]); d_correct = false; assert(isequal(isSortedClockwise(x,y),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
x = [1,1,2,2]; y = [2,1,1,2]; assert(isequal(isSortedClockwise(x,y),false));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint7 (line 3) In solutionTest (line 15)]

8   Pass
x = flip([1,1,2,2]); y = flip([2,1,1,2]); assert(isequal(isSortedClockwise(x,y),true));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint8 (line 3) In solutionTest (line 17)]

9   Pass
x = [-2,-2,-4,-4]; y = [1,3,1,-1]; assert(isequal(isSortedClockwise(x,y),false));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint9 (line 3) In solutionTest (line 19)]

10   Pass
x = flip([-2,-2,-4,-4]); y = flip([1,3,1,-1]); assert(isequal(isSortedClockwise(x,y),true));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint10 (line 3) In solutionTest (line 21)]

11   Pass
r=rand(100,15); a=2*pi*rand(100,1); d=2*(rand(100,1)>.5)-1; x=r.*cos(a*ones(1,15)+d*2*pi*(0:14)/15)+randn(100,1); y=r.*sin(a*ones(1,15)+d*2*pi*(0:14)/15)+randn(100,1); assert(all(arrayfun(@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0),1:100)))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isSortedClockwise (line 2) In ScoringEngineTestPoint11>@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)<0) In ScoringEngineTestPoint11 (line 6) In solutionTest (line 23)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you re...