Cody

Solution 2445675

Submitted on 1 Jun 2020
  • Size: 18
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.');

Addition is forbidden.

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

z = 8 9 5 6 -5 -1

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

Error using bitcmp Bitcmp does not accept complex operands. Error in g (line 2) z = x + bitcmp(y, 'int64')+1 Error in Test3 (line 4) assert(isequal(g(x, y), z))

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

z = 0

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

z = 7

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

z = -10

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

z = 10

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

z = 1641975

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

Error using bitcmp Double inputs must have integer values in the range of ASSUMEDTYPE. Error in g (line 2) z = x + bitcmp(y, 'int64')+1 Error in Test9 (line 1) assert(isequal(g(-3.1, -3.1), 0))

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

Error using bitcmp Bitcmp does not accept complex operands. Error in g (line 2) z = x + bitcmp(y, 'int64')+1 Error in Test10 (line 1) assert(isequal(g(1 + i, i - 1), 2))

Suggested Problems

More from this Author9