From c81b789d32d280ce8c9c5da5022798619e8ee7a6 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 28 Apr 2024 09:38:33 +0200 Subject: Fix columns() --- gen/prop/bool-props.py | 2 +- gen/prop/gc | 2 +- gen/prop/lib.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/prop/bool-props.py b/gen/prop/bool-props.py index 32a293e..c0f9d05 100755 --- a/gen/prop/bool-props.py +++ b/gen/prop/bool-props.py @@ -44,7 +44,7 @@ def genfile(cs: list[tuple[bool, ...]], blksize: int) -> None: print() bcnt = blksize // 8 - bpc = columns(bcnt) + bpc = columns(bcnt, 5) print(f'static constexpr unsigned char stage2[][{bcnt}] = {{') for c in cs: x = sum(map(lambda x: x[1] << x[0], enumerate(c))) diff --git a/gen/prop/gc b/gen/prop/gc index 4f95242..f37cb4b 100755 --- a/gen/prop/gc +++ b/gen/prop/gc @@ -40,7 +40,7 @@ def genfile(cs: list[tuple[bool, ...]], blksize: int) -> None: print() - ppc = columns(blksize) + ppc = columns(blksize, 6) print(f'static constexpr enum uprop_gc stage2[][{blksize}] = {{') for c in cs: for i in range(blksize // ppc): diff --git a/gen/prop/lib.py b/gen/prop/lib.py index 0912208..e71fcf0 100644 --- a/gen/prop/lib.py +++ b/gen/prop/lib.py @@ -14,13 +14,13 @@ def powers_of_2() -> Generator[int, None, None]: yield 2 ** i i += 1 -def columns(n: int) -> int: +def columns(n: int, m: int) -> int: xs = list(set(functools.reduce(list.__add__, ( [i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0) ))) for x in sorted(xs, reverse=True): y = 5 - y += x * 5 + y += x * m y += x - 1 if y <= 80: return x -- cgit v1.2.3