# Differences

Hi all,

How do I program the Arduino Uno to complete a certain task if, out of 5 constantly updated values, 2 are greater than their predecessors and the other 2 are greater than or equal to them?

P.S. I know there is a really long method but I was wondering if there was a simple solution.

Thanks,
Chessy

P.S. I know there is a really long method

Put that really long process in a function. Then, it’s a one line call.

No, there are no shortcuts.

chessy: out of 5 constantly updated values, 2 are greater than their predecessors and the other 2 are greater than or equal to them?

Did you mean "the other three" or "two of the other three" or "out of 4 constantly updates values"?!?

And are you comparing them one to one oldX < newX or one to all?

In the first case it’s pretty trivial set of 5 if and incrementing a 2 counters (strictlyGreater and greaterOrEqual) if your conditions are met then you just return the Boolean value of ((strictlyGreater >= 2) && (greaterOrEqual >= 5-strictlyGreater))