EvenOdd
Jump to navigation
Jump to search
I realized that even and odd numbers can be thought as 0 and 1, so I can make logic gates, or as I call them, parity gates
And
a*b this is an and because look even even: 2*2=4, even even odd: 2*3=6, even odd even: 3*2=6, even odd odd: 3*3=9, odd
Xor
a+b this is an xor because look even even: 2+2=4, even even odd: 2+3=5, odd odd even: 3+2=5, odd odd odd: 3+3=6, even
Nand
you can use the stuff I shown to make an nand gate 1+(a*b) you could probably break this apart to figure this out
The actual structure
def a(some symbol)b: (some code) or def (some symbol): (some code) this defines a gate
And and Not
def a&b: a*b def !a: a+1 def a@b: !(a&b)