Cody

# Problem 193. Smallest distance between a point and a rectangle

Solution 1936084

Submitted on 14 Sep 2019 by nachi
• Size: 9
• 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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','distanceRectangle2Point.m')

2   Pass
x = [-1,-1]; y = [1,1]; z = [4,5]; assert(isequal(distanceRectangle2Point(x,y,z),5)) d_correct = 5;

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

3   Pass
x = [-2,-1]; y = [3,1]; z = [1,2]; assert(isequal(distanceRectangle2Point(x,y,z),1)) d_correct = 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 distanceRectangle2Point (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
x = [1,2]; y = [3,4]; z = [-5,3]; assert(isequal(distanceRectangle2Point(x,y,z),6)) d_correct = 6;

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

5   Pass
x = [2,2]; y = [4,4]; z = [3,4]; assert(isequal(distanceRectangle2Point(x,y,z),0)) d_correct = 0;

[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 distanceRectangle2Point (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
x = [-1,0,1]; y = [0,2,4]; z = [4,5,3]; assert(isequal(distanceRectangle2Point(x,y,z),5)) d_correct = 5;

[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 distanceRectangle2Point (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
x = [1,0,1]; y = [2,3,2]; z = [-1,-2,3]; assert(isequal(distanceRectangle2Point(x,y,z),3)) d_correct = 3;

[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 distanceRectangle2Point (line 2) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)]