Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We can show conditions for AND, OR by simple codes:

def funAnd():
if condition1 and condition2:
return True
#######
0 | 0 -> 0
0 | 1 -> 0
1 | 0 -> 0
1 | 1 -> 1

def funOr():

if condition1 or condition2:
return True
#######
0 | 0 -> 0
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 1
#######################################
what about generating conditional tests for XOR, NAND, NOR, XNOR logics.
########## XOR
0 | 0 -> 0
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 1

########## NAND
0 | 0 -> 1
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 0

########## NOR
0 | 0 -> 1
0 | 1 -> 0
1 | 0 -> 0
1 | 1 -> 0

########## XNOR
0 | 0 -> 1
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 0

How can we test for these logic?
Posted

1 solution

Check the rules, for example as far as I recall NAND is merely Not AND. Coding the rules should be fairly simple, given that the basics are part of most languages.
 
Share this answer
 
Comments
nischalinn 7-Feb-12 10:03am    
will you please elaborate your answer and provide some examples.
Thank you.
Richard MacCutchan 7-Feb-12 10:12am    
See section 5.8 here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900