Last active
May 10, 2016 11:53
-
-
Save u8sand/8c78ed0aeb1b198d37ff to your computer and use it in GitHub Desktop.
Generate simple n-bit truth tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Generate a truth table ''' | |
from itertools import product | |
import sys | |
args = sys.argv[1:] | |
if args!=[]: | |
bits = int(args[0]) | |
sep1 = '\t' if len(args)<=1 else args[1] | |
sep2 = '\n' if len(args)<=2 else args[2] | |
print(sep2.join([sep1.join(map(str,l)) for l in product(*[(0,1)]*bits))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment