Optmize logic IF statement
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))