Problem 44896. Parsing Expressions - Binary Arithmetic Operators I

Solution 1859036

Submitted on 27 Jun 2019 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
% 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

Suggested Problems

More from this Author2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!