Cody

Solution 2216829

Submitted on 17 Apr 2020 by Asif Newaz
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
% Generate and test 100 random binary expressions. operators = '+-*'; for k = 1:100 a = randi(101) - 51; b = randi(101) - 51; op = operators(randi(numel(operators))); expr = sprintf('%d %1s %d', a, op, b); y_correct = eval(expr); assert(isequal(parse_binary_expression(expr),y_correct)) end

y = -1540 y = -952 y = 74 y = -65 y = -50 y = 41 y = -7 y = 49 y = -4 y = 21 y = 20 y = 6 y = 180 y = 25 y = 75 y = 1504 y = -20 y = -8 y = -28 y = 54 y = 26 y = -19 y = 450 y = 42 y = -45 y = 43 y = -16 y = -57 y = -275 y = 18 y = -23 y = -80 y = -47 y = 52 y = 14 y = 0 y = -34 y = -186 y = 23 y = -2 y = 6 y = -1395 y = 24 y = -74 y = 18 y = 17 y = -51 y = -18 y = 870 y = 0 y = 36 y = 1530 y = 64 y = 12 y = -45 y = 90 y = 17 y = 1482 y = 17 y = 1008 y = 4 y = 7 y = 22 y = 44 y = 559 y = -3 y = -20 y = 1 y = 0 y = -5 y = 37 y = -1058 y = 0 y = -400 y = 20 y = 52 y = -1088 y = -22 y = -26 y = 750 y = -3 y = 7 y = 2 y = 450 y = 1 y = -31 y = -220 y = 3 y = 222 y = 8 y = 9 y = 0 y = 33 y = 52 y = -75 y = 340 y = 17 y = 14 y = -450 y = 82