Cody

Problem 46654. Inequalities

Solution 3186786

Submitted on 13 Oct 2020 by Binbin Qi
  • Size: 41
  • This is the leading solution.
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
inequality = '2x + 3y >= 24'; point = [0, 0] y_correct = 0; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 0

2   Pass
inequality = '2x + 3y >= 24'; point = [0, 8] y_correct = 1; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 8

3   Pass
inequality = 'x + 7y > 84'; point = [0, 12] y_correct = 0; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 12

4   Pass
inequality = 'x + y < -5'; point = [-5, 0] y_correct = 0; assert(isequal(checkPoint(inequality, point),y_correct))

point = -5 0

5   Pass
inequality = '-x + y < -5'; point = [1, -10] y_correct = 1; assert(isequal(checkPoint(inequality, point),y_correct))

point = 1 -10

6   Pass
inequality = '-9x - 8y <= -15'; point = [0, 0] y_correct = 0; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 0

7   Pass
inequality = '1/2x - 8/7y <= 9/8'; point = [0, 0] y_correct = 1; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 0

8   Pass
inequality = '0.875x - y > 15.75'; point = [50, -90] y_correct = 1; assert(isequal(checkPoint(inequality, point),y_correct))

point = 50 -90

9   Pass
inequality = '8/7y <= 9/8'; point = [0, 70] y_correct = 0; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 70

10   Pass
inequality = '9x <= 80'; point = [0, 7] y_correct = 1; assert(isequal(checkPoint(inequality, point),y_correct))

point = 0 7

11   Pass
inequality = '5x + 4y <= 60'; for idx = 1:20 point = randi([-50, 50],1,2); y_correct = 5*point(1) + 4*point(2) <= 60; assert(isequal(checkPoint(inequality, point),y_correct)) end

Suggested Problems

More from this Author67

Community Treasure Hunt

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

Start Hunting!