Cody

# Problem 44896. Parsing Expressions - Binary Arithmetic Operators I

Solution 1796238

Submitted on 24 Apr 2019 by praharsh
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 = 37 y = -23 y = 816 y = 74 y = 13 y = -108 y = -165 y = -22 y = -20 y = -26 y = 110 y = 9 y = -27 y = -3 y = 819 y = -9 y = 30 y = -798 y = -4 y = 57 y = -13 y = 64 y = 35 y = -429 y = 32 y = -53 y = 16 y = 172 y = 0 y = 1176 y = -73 y = 22 y = -10 y = -74 y = -45 y = 1 y = 41 y = -1305 y = -558 y = 30 y = 123 y = -21 y = -1 y = 110 y = 351 y = 552 y = -11 y = -19 y = 66 y = -504 y = -2 y = 196 y = 5 y = 12 y = 962 y = 12 y = -1225 y = -25 y = -73 y = 71 y = 16 y = -9 y = 47 y = 644 y = -23 y = 4 y = 39 y = -97 y = 19 y = 24 y = -85 y = 30 y = 9 y = 598 y = -697 y = -308 y = 184 y = -52 y = -540 y = 14 y = -11 y = -37 y = 1764 y = 5 y = -338 y = 21 y = -180 y = -29 y = -29 y = -448 y = -31 y = 2 y = -750 y = 11 y = -380 y = 972 y = 40 y = 760 y = 54 y = 4