Skip to content
Snippets Groups Projects
Commit 895dbe62 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Add generator for Valmari's complexity example

parents
Branches
No related tags found
No related merge requests found
#!/usr/bin/env python
import sys
def gen_functor():
print("3x(PX)\n")
def gen_state(block, column, row):
print("s_%d_%d: (%s, {s_%d_0})" % (column, row, block, column+1))
def gen_final_state(h):
print("s_%d_0: (2, {s_%d_0})" % (h+1, h+1))
def gen_n_states(block, column, n):
for row in range(0, n):
gen_state(block, column, row)
def gen_column(h, column):
if column == 0:
gen_n_states("0", column, 2**h)
else:
gen_n_states("1", column, 2**(column-1))
def gen_all(h):
gen_functor()
gen_final_state(h)
for column in reversed(range(0, h+1)):
gen_column(h, column)
def main(args):
if len(args) != 2:
print("Usage: %s h" % args[0])
sys.exit(1)
h = int(args[1])
gen_all(h)
if __name__ == "__main__":
main(sys.argv)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment