Dec-20-2016, 04:19 PM
Hi all, I'm pretty new to python and I've this problem.
I've the following json:
where A, for example, is this JSON object:
The problems is to return a string representing the Sum Of Product of the original formula. That is:
For example the result would be:
I've the following json:
{ "condition": "AND", "rules": [ { "condition": "OR", "rules": [ { "id": "u.url", "operator": "contains", "value": "URL_A" }, { "id": "u.url", "operator": "contains", "value": "URL_B" } ] }, { "condition": "OR", "rules": [ { "id": "u.url", "operator": "contains", "value": "URL_C" }, { "id": "u.url", "operator": "contains", "value": "URL_D" } ] } ] }representing the boolean formula:
(A or B) and (C or D)
where A, for example, is this JSON object:
{ "id": "u.url", "operator": "contains", "value": "URL_A" }In general, the JSON file could represent any boolean logic with (only) AND and OR operators.
The problems is to return a string representing the Sum Of Product of the original formula. That is:
(A or C) and (A or D) and (B or C) and (B or D)
For example the result would be:
(u.url contains URL_A) OR (u.url contains URL_C) AND (u.url contains URL_A) OR (u.url contains URL_D) AND (u.url contains URL_B) OR (u.url contains URL_C) AND (u.url contains URL_B) OR (u.url contains URL_D)I've no idea how to solve this problem, please can you help me?