Generating the look - up table while pre - processing
def P2 ( n , table ) : NEW_LINE INDENT table . extend ( [ n , n ^ 1 , n ^ 1 , n ] ) NEW_LINE DEDENT def P4 ( n , table ) : NEW_LINE INDENT return ( P2 ( n , table ) , P2 ( n ^ 1 , table ) , P2 ( n ^ 1 , table ) , P2 ( n , table ) ) NEW_LINE DEDENT def P6 ( n , table ) : NEW_LINE INDENT return ( P4 ( n , table ) , P4 ( n ^ 1 , table ) , P4 ( n ^ 1 , table ) , P4 ( n , table ) ) NEW_LINE DEDENT def LOOK_UP ( table ) : NEW_LINE INDENT return ( P6 ( 0 , table ) , P6 ( 1 , table ) , P6 ( 1 , table ) , P6 ( 0 , table ) ) NEW_LINE DEDENT