If operator next to current operand is XOR ( Assuming a valid input )
else { if ( ( $ i + 2 ) < $ n && $ s [ $ i + 2 ] == $ s [ $ i ] ) $ s [ $ i + 2 ] = '0' ; else $ s [ $ i + 2 ] = '1' ; } } return $ s [ $ n - 1 ] - '0' ; }