Optmize logic IF statement I have a little dilema with such if statement, I have tried optimizing it in order to remove some checks, but could not think of how to make this code part cleaner. Can someone please make a review, and tell if it's possible to optimize such statement of maybe there is some law for this? Thank you

//letter = 'E' or 'R' ( char )
//second letter = 'Q' or 'A' ( char )
//DoFlip = false or true ( bool )

if((letter == 'E' &amp;&amp; secondLetter == 'Q' &amp;&amp; DoFlip == false)    || 
       (letter == 'E' &amp;&amp; secondLetter == 'A' &amp;&amp; DoFlip == true) ||
       (letter == 'R' &amp;&amp; secondLetter == 'Q' &amp;&amp; DoFlip == false)||
       (letter == 'R' &amp;&amp; secondLetter == 'A' &amp;&amp; DoFlip== true))
    {
      //DoSmth here
    }
Firstly, this can be rewritten as:


if(((letter == 'E' || letter == 'R')&amp;&amp; secondLetter == 'Q' &amp;&amp; DoFlip == false)|| 
   ((letter == 'E' || letter == 'R') &amp;&amp; secondLetter == 'A' &amp;&amp; DoFlip == true)
    {
      //DoSmth here
    }


According to distributive law - 

A &amp;&amp; B || A &amp;&amp; C = (B || C) &amp;&amp; A


In your logic - (letter == 'E' || letter == 'R') can take place of A with (secondLetter == 'Q' &amp;&amp; DoFlip == false) as B and (secondLetter == 'A' &amp;&amp; DoFlip == true) as C.

So your logic can be simplified to - 

if((letter == 'E' || letter == 'R') &amp;&amp; 
   ((secondLetter == 'Q' &amp;&amp; DoFlip == false) || 
   (secondLetter == 'A' &amp;&amp; DoFlip == true))