Twelve statements: Difference between revisions
Content deleted Content added
m Localized one enum in D entry |
→{{header|Python}}: Add text on True,False == 1,0 in numerical contexts. |
||
Line 470: | Line 470: | ||
Note: we choose to adapt the statement numbering to zero-based indexing in the constraintinfo lambda expressions but convert back to one-based on output. |
Note: we choose to adapt the statement numbering to zero-based indexing in the constraintinfo lambda expressions but convert back to one-based on output. |
||
The program uses brute force to generate all possible boolean values of the twelve statements then checks if the actual value of the statements matches the proposed or matches apart from exactly one deviation. |
The program uses brute force to generate all possible boolean values of the twelve statements then checks if the actual value of the statements matches the proposed or matches apart from exactly one deviation. Pythons' boolean values True, False are converted to the integer values one, zero in numerical contexts. This fact is used in the lambda expressions that use function sum. |
||
<lang python> |
<lang python> |
||
from itertools import product |
from itertools import product |