Skip to content

Instantly share code, notes, and snippets.

View zwegner's full-sized avatar

Zach Wegner zwegner

  • Austin, TX, USA
View GitHub Profile
@zwegner
zwegner / gist:0202c60b9410d029b5cfc5c5643e3374
Last active January 13, 2020 07:07 — forked from dougallj/gist:9211fd24c3759f7f340dede28929c659
Ternary logic multiplication (0, 1, unknown)
import itertools
N_BITS = 8
MASK = (1 << N_BITS) - 1
# Bit class, which stores values as a truth table of up to two variables
class Bit:
def __init__(self, op, bit_a=None, bit_b=None):
self.op = op
# Remove variables when the truth table doesn't depend on them