cases = (True, False)

for case_1 in cases:
    for case_2 in cases:
        for case_3 in cases:
            print 'Input: {}, {}, {}'.format(
            	case_1, case_2, case_3
            )
            print ' - old condition: {}'.format(
            	not (case_2 and case_1 and not case_3 or (not case_2 and case_1 and case_3))
            )
            print ' - refactored condition (current): {}'.format(
            	case_1 and not (case_2 ^ case_3)
            )
            print ' - fixed condition: {}\n'.format(
            	not case_1 or case_1 and not (case_2 ^ case_3)
            )