Cody

# Problem 1651. Circumcircle Points

Solution 2056059

Submitted on 12 Dec 2019 by William
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
pts=[0 0;5 0;1.8 2.4]; % 3 4 5 triangle r_exp=2.5; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

2   Pass
pts=[0 0;6 0;1.8 2.4]; % 3 x 6 triangle r_exp=3; % Two Point Solver r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

3   Pass
pts=[0 0;0 1;1 2;3 0]; % r^2=2.5 r_exp=sqrt(2.5); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

4   Pass
pts=[0 1; 0 3; 0 4; 2 6; 3 0; 4 5]; % r2 9.2820069 r_exp=sqrt(9.2820069 ); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

[Warning: Matrix is singular to working precision.] [> In Circumcircle_radius>find_circle (line 38) In Circumcircle_radius (line 27) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 976) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/OutputPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/FiguresPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In matlab.unittest.plugins/DiagnosticsRecordingPlugin/runTestSuite (line 199) In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest.internal/SerialTestRunStrategy/runSession (line 21) In matlab.unittest/TestRunner/runSession (line 937) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest/TestRunner/doRunWithFcn (line 409) In matlab.unittest/TestRunner/run (line 297) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ]

5   Pass
pts=[0,2;0,6;1,1;3,0;3,3;4,10;5,10;7,2;9,7]; % r2 26.6919 r_exp=sqrt(26.6919420552286 ); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

6   Pass
pts=[0,19;1,25;1,30;1,34;3,11;4,30;8,17;9,6;11,44;12,45;15,46;21,0;21,9;21,48;22,42;26,11;31,40;34,27;37,44;39,34;41,8;43,9;43,10;46,16;46,35;48,23]; % r2 exp 608.7807 r_exp=sqrt(608.780718525455); r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

[Warning: Matrix is singular to working precision.] [> In Circumcircle_radius>find_circle (line 38) In Circumcircle_radius (line 27) In ScoringEngineTestPoint6 (line 3) In solutionTest (line 13) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 976) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/OutputPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/FiguresPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In matlab.unittest.plugins/DiagnosticsRecordingPlugin/runTestSuite (line 199) In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest.internal/SerialTestRunStrategy/runSession (line 21) In matlab.unittest/TestRunner/runSession (line 937) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest/TestRunner/doRunWithFcn (line 409) In matlab.unittest/TestRunner/run (line 297) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.832114e-20.] [> In Circumcircle_radius>find_circle (line 38) In Circumcircle_radius (line 27) In ScoringEngineTestPoint6 (line 3) In solutionTest (line 13) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 976) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/OutputPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/FiguresPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In matlab.unittest.plugins/DiagnosticsRecordingPlugin/runTestSuite (line 199) In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest.internal/SerialTestRunStrategy/runSession (line 21) In matlab.unittest/TestRunner/runSession (line 937) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest/TestRunner/doRunWithFcn (line 409) In matlab.unittest/TestRunner/run (line 297) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.683643e-20.] [> In Circumcircle_radius>find_circle (line 38) In Circumcircle_radius (line 27) In ScoringEngineTestPoint6 (line 3) In solutionTest (line 13) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invo...

7   Pass
% Random case to avoid hard coders xc=rand; yc=rand; r=.5+rand; pts=[]; % Equilateral points pts(1,:)=[xc+r,yc]; pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)]; pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)]; for i=4:10 rnew=rand*r; theta=randi(360)*pi/180; pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)]; end pts=pts(randperm(size(pts,1)),:); r_exp=r; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)

8   Pass
% Random case to avoid hard coders xc=rand; yc=rand; r=.5+rand; pts=[]; % Equilateral points pts(1,:)=[xc+r,yc]; pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)]; pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)]; for i=4:30 rnew=rand*r; theta=randi(360)*pi/180; pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)]; end pts=pts(randperm(size(pts,1)),:); r_exp=r; r = Circumcircle_radius(pts); assert(abs(r-r_exp)<.001)