Cody

Solution 2090206

Submitted on 12 Jan 2020 by Binbin Qi
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('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, 'times')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'cumprod')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'mtimes')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'dot')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'cross')), 'Multiplication is forbidden.') assert(isempty(strfind(filetext, 'mldivide')), 'Division is forbidden.') assert(isempty(strfind(filetext, '\')), 'Division is forbidden.') assert(isempty(strfind(filetext, 'mrdivide')), 'Division is forbidden.') assert(isempty(strfind(filetext, '/')), 'Division is forbidden.') assert(isempty(strfind(filetext, '+')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'add')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'sum')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'plus')), 'Addition is forbidden.') assert(isempty(strfind(filetext, 'mean')), '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, 'exp')), '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, 'var')), 'Variance is forbidden.') assert(isempty(strfind(filetext, 'filter')), 'Filter is forbidden.') assert(isempty(strfind(filetext, 'fft')), 'fft 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, 'e')), 'Eval is forbidden.'); assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'system')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'command')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.'); assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.'); assert(isempty(strfind(filetext, 'pcode')), 'pcode is forbidden.'); assert(isempty(strfind(filetext, 'rehash')), 'rehash is forbidden.'); assert(isempty(strfind(filetext, 'path')), 'path is forbidden.'); assert(isempty(strfind(filetext, 'set')), 'set* is forbidden.'); assert(isempty(strfind(filetext, '@')), 'Anonymous functions are forbidden.');

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

x = 10 15 2 9 8 12

3   Pass
x = magic(4); y = sqrtm(x); z = x + y; assert(isequal(g(x, y), z))

x = 19.7584 - 0.2071i 1.7729 + 0.4886i 3.3887 + 0.7700i 14.9110 - 1.0514i 5.2745 - 0.0130i 13.3243 + 0.0306i 12.0076 + 0.0483i 9.2246 - 0.0659i 10.3918 - 0.2331i 8.5060 + 0.5498i 7.4884 + 0.8666i 13.4447 - 1.1833i 4.4063 + 0.4533i 16.2277 - 1.0691i 16.9463 - 1.6848i 2.2506 + 2.3006i

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

x = 2

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

x = -10

6   Pass
assert(isequal(g(987654, 654321), 1641975))

x = 1641975

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

x = 0

8   Pass
assert(isequal(g(1 + i, i - 1), 2*i))

x = 0.0000 + 2.0000i