Search code examples
expressionsimplify

Can you simplify this expression?


One for the mathematicians. This has gone around the office and we want to see who can come up with a better optimised version.

(((a+p) <= b) && (a == 0 || a > 1) && (b >= p)) && 
    ((b - (a + p) == 0) || (b - (a + p) > 1))

Edit: all data is positive int's

Edit: Better == simpler


Solution

  • (a + p <= b) && (a != 1) && (b - a - p != 1);