Search code examples
pythonvariableslogical-operators

Logical NAND of two variables in Python


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.


Solution

  • 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)