(Python)
from itertools import zip_longest
from sympy.ntheory.factor_ import digits
from networkx import empty_graph, find_cliques
k = 1<<(n<<1)
G = empty_graph(range(k))
G.add_edges_from((a, b) for a in range(k) for b in range(a) if (s:=tuple(c-d&3 for c, d in zip_longest(digits(a, 4)[-1:0:-1], digits(b, 4)[-1:0:-1], fillvalue=0))).count(2)==0 or s.count(0)>len(s)-2)
return sum(1 for c in find_cliques(G)) # Chai Wah Wu, Jan 11 2024
|