Cody

# Problem 44457. Triangle of numbers

Solution 2847240

Submitted on 18 Aug 2020 by Raghunadh N
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
filetext = fileread('triangle.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
n = 0; mat_correct = []; assert(isequal(triangle(n),mat_correct))

[Warning: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint2 (line 3) In solutionTest (line 5) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 ] ans = []

3   Pass
n = 1; mat_correct = 1; assert(isequal(triangle(n),mat_correct))

[Warning: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 ] ans = 1

4   Pass
n = 6; mat_correct = [1 0 0; 2 3 0; 4 5 6]; assert(isequal(triangle(n),mat_correct))

[Warning: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 ] ans = 1 0 0 2 3 0 4 5 6

5   Pass
n = 12; mat_correct = [1 0 0 0; 2 3 0 0; 4 5 6 0; 7 8 9 10; 11 12 0 0]; assert(isequal(triangle(n),mat_correct))

[Warning: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 ] ans = 1 0 0 0 2 3 0 0 4 5 6 0 7 8 9 10 11 12 0 0

6   Pass
n = 50; mat_correct = [1,zeros(1,8); 2:3,zeros(1,7); 4:6,zeros(1,6); 7:10,zeros(1,5); 11:15,zeros(1,4); 16:21,zeros(1,3); 22:28,0,0; ; 29:36,0; 37:45; 46:50,zeros(1,4)]; assert(isequal(triangle(n),mat_correct))

[Warning: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint6 (line 5) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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: Input should be a string, character array, or cell array of character arrays.] [> In triangle (line 5) In ScoringEngineTestPoint6 (line 5) 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 873) In matlab.unittest/TestRunner/evaluateMethod (line 1190) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 815) In matlab.unittest/TestRunner/runTestMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 1133) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1042) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 979) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 201) 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 22) In matlab.unittest/TestRunner/runSession (line 940) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 928) 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 ] ans = 1 0 0 0 0 0 0 0 0 2 3 0 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 7 8 9 10 0 0 0 0 0 11 12 13 14 15 0 0 0 0 16 17 18 19 20 21 0 0 0 22 23 24 25 26 27 28 0 0 29 30 31 32 33 34 35 36 0 37 38 39 40 41 42 43 44 45 46 47 48 49 50 0 0 0 0

### Community Treasure Hunt

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

Start Hunting!