Cody

Problem 1826. Find vampire numbers

Solution 1471240

Submitted on 26 Mar 2018 by Gareth Lee
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
x = 1000:2000; v = find_vampire(x); v_correct = [1260 1395 1435 1530 1827]; assert(isequal(v,v_correct))

2   Pass
x = 1:999; v = find_vampire(x); assert(isempty(v))

3   Pass
x = reshape(2000:2999,100,[]); v = find_vampire(x); v_correct = 2187; assert(isequal(v,v_correct))

4   Pass
x = []; v = find_vampire(x); assert(isempty(v))

5   Pass
x = -2000:-1000; v = find_vampire(x); assert(isempty(v))

[Warning: Colon operands must be real scalars.] [> In find_vampire>@(a)any(arrayfun(@(i)~rem(a,i)&&(rem(a,100)|rem(i,10))&&isequal(sort(num2str(a)),sort(reshape(num2str([i;a/i]),1,''))),1:sqrt(a))) (line 3) In find_vampire (line 2) In ScoringEngineTestPoint5 (line 2) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 841) In matlab.unittest.TestRunner/evaluateMethod (line 1141) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 783) In matlab.unittest.TestRunner/runTestMethod (line 1137) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTest (line 1084) In matlab.unittest.TestRunner/repeatTest (line 471) In matlab.unittest.TestRunner/runSharedTestCase (line 427) In matlab.unittest.TestRunner/runTestClass (line 994) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTestSuite (line 931) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 184) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/run (line 295) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Colon operands must be real scalars.] [> In find_vampire>@(a)any(arrayfun(@(i)~rem(a,i)&&(rem(a,100)|rem(i,10))&&isequal(sort(num2str(a)),sort(reshape(num2str([i;a/i]),1,''))),1:sqrt(a))) (line 3) In find_vampire (line 2) In ScoringEngineTestPoint5 (line 2) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 841) In matlab.unittest.TestRunner/evaluateMethod (line 1141) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 783) In matlab.unittest.TestRunner/runTestMethod (line 1137) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTest (line 1084) In matlab.unittest.TestRunner/repeatTest (line 471) In matlab.unittest.TestRunner/runSharedTestCase (line 427) In matlab.unittest.TestRunner/runTestClass (line 994) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTestSuite (line 931) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (line 184) In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/run (line 295) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] [Warning: Colon operands must be real scalars.] [> In find_vampire>@(a)any(arrayfun(@(i)~rem(a,i)&&(rem(a,100)|rem(i,10))&&isequal(sort(num2str(a)),sort(reshape(num2str([i;a/i]),1,''))),1:sqrt(a))) (line 3) In find_vampire (line 2) In ScoringEngineTestPoint5 (line 2) 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 98) In matlab.unittest.TestRunner/evaluateMethodCore (line 841) In matlab.unittest.TestRunner/evaluateMethod (line 1141) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.OutputPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/evaluateMethod (line 679) In scoringengine.FiguresPlugin/evaluateMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/evaluateMethodsOnTestContent (line 783) In matlab.unittest.TestRunner/runTestMethod (line 1137) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.OutputPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestMethod (line 633) In scoringengine.FiguresPlugin/runTestMethod In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTest (line 1084) In matlab.unittest.TestRunner/repeatTest (line 471) In matlab.unittest.TestRunner/runSharedTestCase (line 427) In matlab.unittest.TestRunner/runTestClass (line 994) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.TestRunner/evaluateMethodOnPlugins (line 745) In matlab.unittest.TestRunner/runTestSuite (line 931) In matlab.unittest.TestRunner/invokeTestContentOperatorMethod_ (line 889) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.OutputPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In scoringengine.FiguresPlugin/runTestSuite In matlab.unittest.plugins.TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 710) In matlab.unittest.plugins.TestRunnerPlugin/runTestSuite (line 250) In matlab.unittest.plugins.DiagnosticsRecordingPlugin/runTestSuite (...

6   Pass
x = 125000:125501; v = find_vampire(x); v_correct = [125248 125433 125460 125500]; assert(isequal(v,v_correct))