You will write three small functions that test points against the rules of a feasible region. The checker tests them on many rules and points.
The idea. A rule is a tuple (a, b, sign, c), which stands for compared with . The sign is the text "<=" or ">=". A point is feasible if , and it obeys every rule.
Your tasks.
satisfies(rule, x, y). Return True if the point obeys that one rule.is_feasible(rules, x, y). Return True if , and the point obeys every rule.count_points(rules, n). Count the feasible points with whole-number coordinates from 0 to n.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…