Cody

# Problem 45266. Restricted Subtraction v1

Solution 2131078

Submitted on 17 Feb 2020
• Size: 35
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   Fail
filetext = fileread('g.m'); filetext(find(filetext == '%', 1, 'last') : end) = []; assert(isempty(strfind(filetext, '*')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'prod')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'cumprod')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'dot')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'cross')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, '\')), 'Division is forbidden.') assert(isempty(strfind(filetext, '/')), 'Division is forbidden.') assert(isempty(strfind(filetext, '+')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'sum')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'plus')), 'Addition is forbidden.') assert(isempty(strfind(filetext, '-')), 'Subtraction is forbidden.') assert(isempty(strfind(filetext, 'minus')), 'Subtraction is forbidden.') assert(isempty(strfind(filetext, 'diff')), 'Subtraction is forbidden.') assert(isempty(strfind(filetext, '^')), 'Exponeniation is forbidden.'); assert(isempty(strfind(filetext, 'log')), 'logarithms are forbidden.'); assert(isempty(strfind(filetext, 'conv')), 'Convolution is forbidden.') assert(isempty(strfind(filetext, 'corr')), 'Correlation is forbidden.') assert(isempty(strfind(filetext, 'cov')), 'Covariance is forbidden.') assert(isempty(strfind(filetext, 'std')), 'Variance is forbidden.') assert(isempty(strfind(filetext, 'poly')), 'Polynomials are forbidden.') assert(isempty(strfind(filetext, 'bit')), 'Bit manipulation is forbidden.') assert(isempty(strfind(filetext, '''')), 'String is forbidden.') assert(isempty(strfind(filetext, '"')), 'String is forbidden.') assert(isempty(strfind(filetext, 'str')), 'String is forbidden.') assert(isempty(strfind(filetext, '2')), 'Conversion is forbidden.'); assert(isempty(strfind(filetext(2 : end), 'f')), 'File handling and figures are forbidden.'); assert(isempty(strfind(filetext, '>')), 'File handling is forbidden.'); assert(isempty(strfind(filetext, 'a')), 'accumarray is forbidden.'); assert(isempty(strfind(filetext, 'e')), 'Eval is forbidden.'); assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.'); assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.'); assert(isempty(strfind(filetext, '@')), 'Anonymous functions are forbidden.');

File handling and figures are forbidden.

2   Fail
rng(now()); x = randi(10, [2 3]); y = randi(10, [2 3]); z = x - y; assert(isequal(g(x, y), z))

j = 9 10

Assertion failed.

3   Fail
x = magic(4); y = sqrtm(x); z = x - y; assert(isequal(g(x, y), z))

[Warning: Colon operands must be real scalars.] [> In g (line 5) In ScoringEngineTestPoint3 (line 4) 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 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 ] j = 3.7584 4.7584 5.7584 6.7584 7.7584 8.7584 9.7584 10.7584 11.7584 12.7584 13.7584 14.7584 15.7584

Assertion failed.

4   Fail
assert(isequal(g(1, 1), 0))

j = 1

Assertion failed.

5   Fail
assert(isequal(g(10, 3), 7))

Assertion failed.

6   Fail
assert(isequal(g(-10, 0), -10))

j = 1×0 empty double row vector

Assertion failed.

7   Fail
assert(isequal(g(0, -10), 10))

Assertion failed.

8   Fail
assert(isequal(g(987654, -654321), 1641975))

Assertion failed.

9   Fail
assert(isequal(g(-3.1, -3.1), 0))

j = -3.1000

Assertion failed.

10   Fail
assert(isequal(g(1 + i, i - 1), 2))

[Warning: Colon operands must be real scalars.] [> In g (line 3) In ScoringEngineTestPoint10 (line 1) 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 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 ]

Assertion failed.