fork download
  1. cases = (True, False)
  2.  
  3. for case_1 in cases:
  4. for case_2 in cases:
  5. for case_3 in cases:
  6. print 'Input: {}, {}, {}'.format(
  7. case_1, case_2, case_3
  8. )
  9. print ' - old condition: {}'.format(
  10. not (case_2 and case_1 and not case_3 or (not case_2 and case_1 and case_3))
  11. )
  12. print ' - refactored condition (current): {}'.format(
  13. case_1 and not (case_2 ^ case_3)
  14. )
  15. print ' - fixed condition: {}\n'.format(
  16. not case_1 or case_1 and not (case_2 ^ case_3)
  17. )
Success #stdin #stdout 0.01s 9024KB
stdin
Standard input is empty
stdout
Input: True, True, True
 - old condition: True
 - refactored condition (current): True
 - fixed condition: True

Input: True, True, False
 - old condition: False
 - refactored condition (current): False
 - fixed condition: False

Input: True, False, True
 - old condition: False
 - refactored condition (current): False
 - fixed condition: False

Input: True, False, False
 - old condition: True
 - refactored condition (current): True
 - fixed condition: True

Input: False, True, True
 - old condition: True
 - refactored condition (current): False
 - fixed condition: True

Input: False, True, False
 - old condition: True
 - refactored condition (current): False
 - fixed condition: True

Input: False, False, True
 - old condition: True
 - refactored condition (current): False
 - fixed condition: True

Input: False, False, False
 - old condition: True
 - refactored condition (current): False
 - fixed condition: True