Cody

Problem 43154. Basics - not so easy division

Solution 2133384

Submitted on 19 Feb 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
x = 1; y=1; z_correct = 1; assert(isequal(dividing(x,y),z_correct))

Unrecognized function or variable 'is'. Error in dividing (line 2) if y == 0 || isnan(x) || isnan(y) || isinf(x) || is inf(y) Error in Test1 (line 4) assert(isequal(dividing(x,y),z_correct))

2   Pass
x = 1; y=0; z_correct = 'ERROR'; assert(isequal(dividing(x,y),z_correct))

ans = []

3   Pass
x = Inf; y=-Inf; z_correct = 'ERROR'; assert(isequal(dividing(x,y),z_correct))

ans = []

4   Fail
x = 1; y=NaN; z_correct = 'ERROR'; assert(isequal(dividing(x,y),z_correct))

Error using inf NaN and Inf not allowed. Error in dividing (line 2) if y == 0 || isnan(x) || isnan(y) || isinf(x) || is inf(y) Error in Test4 (line 4) assert(isequal(dividing(x,y),z_correct))