Cody

# Problem 1385. Perimeter

Solution 1837539

Submitted on 4 Jun 2019 by YIFEI ZHANG
• Size: 7
• 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
xy=[0,0; 1,0; 1,1; 0,1; 0,0]; err=(abs(perimeter1(xy)-4)/(4))*100; assert(err<.1)

[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 perimeter1 (line 2) In ScoringEngineTestPoint1 (line 8) In solutionTest (line 3)]

2   Pass
t=[0:pi/100:2*pi,0]'; xy=[cos(t),sin(t)]; err=(abs(perimeter1(xy)-2*pi)/(2*pi))*100; assert(err<.1)

[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 perimeter1 (line 2) In ScoringEngineTestPoint2 (line 5) In solutionTest (line 5)]

3   Pass
t=[0:pi/100:pi,0]'; xy=[cos(t),sin(t)]; err=(abs(perimeter1(xy)-(pi+2))/(2+pi))*100; assert(err<.1)

[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 perimeter1 (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
side=rand; x=side*[-1 -0.5 0.5 1 0.5 -0.5 -1]; y=side*sqrt(3)*[0 -0.5 -0.5 0 0.5 0.5 0]; xy=[x',y']; err=(abs(perimeter1(xy)-(6*side))/(6*side))*100; assert(err<.1)

[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 perimeter1 (line 2) In ScoringEngineTestPoint4 (line 5) In solutionTest (line 9)]