S
S
Sherbatiy2018-03-22 19:59:38
Algorithms
Sherbatiy, 2018-03-22 19:59:38

How to check multiple ranges of values?

Good afternoon
I work as an analyst and I am engaged in the description of the task for the developer.
Conditions:
The system allows you to create Rules, indicating the allowed numerical values: minimum values, maximum values, a range of values ​​or several ranges of values.
Numeric values ​​are a decimal number with two decimal places.
Task: It is
necessary to describe the algorithm for checking the Rules, which checks them for conflicts with each other.
Example 1:
Rule 1: greater than 5
Rule 2: 10 to 20
Rule 3: less than 8
Example 2:
Rule 1: 2 to 5 and 10 to 15
Rule 2: 6 to 12
I would be grateful for clarifying and leading questions, advice, examples of algorithms for checking the Rules.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Therapyx, 2018-03-22
@Therapyx

The task is interesting, but alas, I definitely won’t have time for all of it right now. But I would start like this,
imagine for example 1 person entered them "somewhere in the GUI".
1) You write a function to convert all possible operators into numbers. For example > eto 1, < eto 2. And vice versa.
2) You go through all the rules that the user entered and add to the container in pairs (operator, number).
3) think through all sorts of combinations of conflictors. In your variant it is visible already at once 3.
If the number from the operator 1 (>) is less, than from the operator 2 (<), then = the conflict.
And according to this principle, you make redneck patterns until you cover all the exceptions.
Ideally, you need to aggregate and make a more complex structure. But I don't think it's needed in your example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question