Logical NAND of two variables in Python

22,271

Solution 1

Interpreting:

Tree 2's x and y both are not the same as Tree 1's x and y

As:

Tree 2's x and y are not both the same as Tree 1's x and y

return (t1.x, t1.y) != (t2.x, t2.y)

Solution 2

Since NAND is the negation of and,

not (a and b) 

should totally work, with a and b as inputs, or do I miss something?

Share:
22,271
Jonathan Spirit
Author by

Jonathan Spirit

Updated on July 09, 2022

Comments

  • Jonathan Spirit
    Jonathan Spirit almost 2 years

    I'm making a function that makes 50 random trees in a 1000 by 1000 area.

    I need to make sure that Tree 2's x and y both are not the same as Tree 1's x and y. This takes a NAND Gate. I'm okay with one of them being the same, I'm okay with neither being the same, but not with both being the same. I can't seem to find anything about making NAND Gates in python. I'm fine with defining a function to make a NAND.