Cody

Problem 44896. Parsing Expressions - Binary Arithmetic Operators I

Solution 2216827

Submitted on 17 Apr 2020
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   Fail
% 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

Error: You may not use the command(s) eval in your code

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!