Cody

Problem 74. Balanced number

Solution 1735512

Submitted on 25 Feb 2019 by Harsha Priya Daggubati
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
n = 13722; assert(isequal(isBalanced(n),true))

[Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] tf = logical 1

2   Pass
n = 23567414; assert(isequal(isBalanced(n),true))

tf = logical 1

3   Pass
n = 20567410; assert(isequal(isBalanced(n),false))

tf = logical 0

4   Pass
n = 1; assert(isequal(isBalanced(n),true))

[Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)] [Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)] tf = logical 1

5   Pass
n = 11111111; assert(isequal(isBalanced(n),true))

tf = logical 1

6   Pass
n = 12345678; assert(isequal(isBalanced(n),false))

tf = logical 0

7   Pass
n = 12333; assert(isequal(isBalanced(n),false))

[Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint7 (line 2) In solutionTest (line 15) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint7 (line 2) In solutionTest (line 15) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] tf = logical 0

8   Pass
n = 9898; assert(isequal(isBalanced(n),true))

tf = logical 1

9   Pass
n = 469200; assert(isequal(isBalanced(n),false))

tf = logical 0

10   Pass
n = 57666; assert(isequal(isBalanced(n),true))

[Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint10 (line 2) In solutionTest (line 21) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Integer operands are required for colon operator when used as index.] [> In isBalanced (line 4) In ScoringEngineTestPoint10 (line 2) In solutionTest (line 21) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 852) In matlab.unittest.TestRunner/evaluateMethod (line 1152) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 655) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 794) In matlab.unittest.TestRunner/runTestMethod (line 1148) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 609) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTest (line 1095) In matlab.unittest.TestRunner/repeatTest (line 482) In matlab.unittest.TestRunner/runSharedTestCase (line 438) In matlab.unittest.TestRunner/runTestClass (line 1005) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/runTestSuite (line 942) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 900) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 226) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 204) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 686) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 756) In matlab.unittest.TestRunner/doRun (line 411) In matlab.unittest.TestRunner/run (line 290) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] tf = logical 1