Cody

Solution 2108637

Submitted on 28 Jan 2020 by Graham
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, '-')), 'Subtraction is forbidden.') assert(isempty(strfind(filetext, 'minus')), 'Subtraction is forbidden.') assert(isempty(strfind(filetext, '^')), 'Exponeniation is forbidden.'); assert(isempty(strfind(filetext, 'exp')), 'Exponeniation 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
assert(isequal(g(1, 1), 2))

3   Pass
assert(isequal(g(10, 0), 10))

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