Cody

# Problem 194. Clockwise or Counterclockwise

Solution 3226753

Submitted on 15 Oct 2020 by Mayank Bajpai
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))

temp = -6 tf = logical 1

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

temp = 3 tf = logical 0

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

temp = 3 tf = logical 0

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

temp = 198 tf = logical 0

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

temp = -1778 tf = logical 1

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

temp = 1778 tf = logical 0

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

temp = 0 tf = logical 0 tf = logical 0

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

temp = 0 tf = logical 0 tf = logical 1

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

temp = 14 tf = logical 0

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

temp = -14 tf = logical 1

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

temp = 1.4718 tf = logical 0 temp = 2.5134 tf = logical 0 temp = -1.1491 tf = logical 1 temp = -1.0335 tf = logical 1 temp = 1.4602 tf = logical 0 temp = 1.6820 tf = logical 0 temp = 1.3635 tf = logical 0 temp = -1.0742 tf = logical 1 temp = 0.7126 tf = logical 0 temp = -2.0074 tf = logical 1 temp = -0.8435 tf = logical 1 temp = 0.7894 tf = logical 0 temp = -2.5019 tf = logical 1 temp = -1.8744 tf = logical 1 temp = -0.9316 tf = logical 1 temp = -1.4600 tf = logical 1 temp = -1.2311 tf = logical 1 temp = 2.3343 tf = logical 0 temp = 2.2736 tf = logical 0 temp = -1.2084 tf = logical 1 temp = -1.7091 tf = logical 1 temp = -0.7248 tf = logical 1 temp = 0.2986 tf = logical 0 temp = -1.3979 tf = logical 1 temp = -0.8011 tf = logical 1 temp = 2.9582 tf = logical 0 temp = -0.3902 tf = logical 1 temp = -0.9239 tf = logical 1 temp = 0.2250 tf = logical 0 temp = 0.8712 tf = logical 0 temp = -1.3227 tf = logical 1 temp = -1.0309 tf = logical 1 temp = -1.3938 tf = logical 1 temp = 1.2729 tf = logical 0 temp = -1.7172 tf = logical 1 temp = 0.8925 tf = logical 0 temp = -2.5881 tf = logical 1 temp = -1.9448 tf = logical 1 temp = 1.1574 tf = logical 0 temp = 0.6284 tf = logical 0 temp = 2.1916 tf = logical 0 temp = -0.6925 tf = logical 1 temp = 1.4573 tf = logical 0 temp = -2.1396 tf = logical 1 temp = 1.8239 tf = logical 0 temp = 2.0619 tf = logical 0 temp = -1.7974 tf = logical 1 temp = -1.3951 tf = logical 1 temp = -1.2833 tf = logical 1 temp = -0.8444 tf = logical 1 temp = 1.3043 tf = logical 0 temp = -1.7429 tf = logical 1 temp = -1.3563 tf = logical 1 temp = -1.9690 tf = logical 1 temp = 1.2843 tf = logical 0 temp = -2.0054 tf = logical 1 temp = -1.7061 tf = logical 1 temp = -2.0669 tf = logical 1 temp = -2.7811 tf = logical 1 temp = -1.4003 tf = logical 1 temp = 0.9243 tf = logical 0 temp = -2.6170 tf = logical 1 temp = -1.3396 tf = logical 1 temp = -1.4557 tf = logical 1 temp = -1.1705 tf = logical 1 temp = -0.8442 tf = logical 1 temp = 1.9817 tf = logical 0 temp = 2.3507 tf = logical 0 temp = 1.3120 tf = logical 0 temp = -1.1191 tf = logical 1 temp = 1.9499 tf = logical 0 temp = -2.5235 tf = logical 1 temp = 1.2813 tf = logical 0 temp = 0.9650 tf = logical 0 temp = 0.9936 tf = logical 0 temp = -1.8692 tf = logical 1 temp = -1.8226 tf = logical 1 temp = 1.7646 tf = logical 0 temp = 1.3197 tf = logical 0 temp = -1.4671 tf = logical 1 temp = 1.3834 tf = logical 0 temp = 2.2562 tf = logical 0 temp = -1.4474 tf = logical 1 temp = -1.4916 tf = logical 1 temp = -1.1883 tf = logical 1 temp = 2.0332 tf = logical 0 temp = 1.0921 tf = logical 0 temp = 1.8351 tf = logical 0 temp = -0.1714 tf = logical 1 temp = 0.9161 tf = logical 0 temp = 1.7002 tf = logical 0 temp = 2.3541 tf = logical 0 temp = -1.9383 tf = logical 1 temp = -0.7440 tf = logical 1 temp = 0.5683 tf = logical 0 temp = -2.8533 tf = logical 1 temp = 1.2497 tf = logical 0 temp = 1.6760 tf = logical 0 temp = 1.6783 tf = logical 0 temp = -1.6201 tf = logical 1

### Community Treasure Hunt

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

Start Hunting!