"""An exact finite check accompanying Hanoi tilings with a prescribed number of bottom squares.""" def check_caps(): # Tables store rectangles certified by strip concatenation, up to width 500. possible = {0: set(range(501)), 1: set(range(1, 501)), 2: set(range(2, 501, 2))} for height in range(3, 100): strips = [side for side in range(1, height + 1) if height - side < side and side in possible[height - side]] widths = {0} for width in range(1, 501): if any(width - side in widths for side in strips): widths.add(width) start = (5 * height + 1) // 2 assert set(range(start, start + height)) <= widths possible[height] = widths if __name__ == "__main__": check_caps() print("Exact finite check passed.")