Expanding a logical statement (multiplying out)

前端 未结 2 1094
误落风尘
误落风尘 2021-01-23 21:16

I am looking for a way to expand a logical expression (in a string) of the form:

\'(A or B) and ((C and D) or E)\'

in Python to produce a list of all positive se

2条回答
  •  温柔的废话
    2021-01-23 21:49

    It sounds as if you want to convert these expressions to Disjunctive Normal Form. A canonical algorithm for doing that is the Quine-McCluskey algorithm; you can find some information about Python implementations thereof in the relevant Wikipedia article and in the answers to this SO question.

提交回复
热议问题