If operator next to current operand is OR .
else if ( ( $ i + 1 ) < $ n && $ s [ $ i + 1 ] = = ' B ' ) { if ( $ s [ $ i + 2 ] == '1' $ s [ $ i ] == '1' ) $ s [ $ i + 2 ] = '1' ; else $ s [ $ i + 2 ] = '0' ; }