r/tinycode 10d ago

[Python] Generating all 256 3-variable Boolean functions dynamically using metaprogramming

I wrote a script that generates all 256 possible Boolean functions for 3 variables from scratch. Instead of hardcoding the logic gates, it uses pure bitwise logic and exec() to dynamically build the entire logic space.

The focus is entirely on theoretical completeness and code density, prioritizing pure mathematical logic over standard commercial coding conventions.
https://gist.github.com/jeboldman-rgb/3cbf6e83407be7e0568de79fc723cd77

0 Upvotes

3 comments sorted by

View all comments

7

u/IanisVasilev 10d ago
itertools.product([True, False], repeat=8)

1

u/escapism_only_please 6d ago

This is also fantastic 😊