title: Detecting if two number ranges clash
body: <p>This is hopefully a very simple maths question. If I have two number ranges, what is the simplest and most efficient way to check if they clash, eg:</p>
  
  <pre><code>10-20 and 11-14 // clash as B is contained in A
  11-15 and 20-22 // don't clash
  24-26 and 20-30 // clash as A is contained in B
  15-25 and 20-30 // clash as they overlap at each end
  </code></pre>
  
  <p>I currently have this mess, but there must be a much simpler way to do this check:</p>
  
  <pre><code>$clash = ($b1 &gt;= $a1 &amp;&amp; $b1 &lt;= $a2)
      || ($b2 &gt;= $a1 &amp;&amp; $b2 &lt;= $a2)
      || ($a1 &gt;= $b1 &amp;&amp; $a1 &lt;= $b2)
      || ($a2 &gt;= $b1 &amp;&amp; $a2 &lt;= $b2);
  </code></pre>