Consider a $n$ by $n$ by $n$ grid represented by the set of $3$-uples $S=\{1,2,\dots, n\}^3$.
A line (resp. slice) of $S$ is a subset of cardinal $n$ (resp. $n^2$) where two components (resp. one component) of the $3$-uples are fixed.
Some boxes of the grid are black (and the remaining ones are white), they are represented by a subset $B \subseteq S$. For a fixed $r \le n$, consider the following assumptions on $B$:
- every line contains exactly $r$ black boxes.
- in every slice, the black boxes can be filled collinearly, i.e. there is an ordering $b_1, b_2, \dots, b_{rn}$ such that for all $i>1$ there is $j<i$ such that $b_i$ and $b_j$ are in a same line.
Example: For $r=2$ and $n = 4$, the following combination (given by the pictures of $4$ parallel slices) satisfies the two above assumptions.
$\substack{ \displaystyle{◻◻◼◼} \cr \displaystyle{◼◼◻◻} \cr \displaystyle{◼◻◼◻} \cr \displaystyle{◻◼◻◼} } $ $\substack{ \displaystyle{◻ ◼ ◼ ◻} \cr \displaystyle{◼ ◻ ◼ ◻} \cr \displaystyle{◻ ◼ ◻ ◼} \cr \displaystyle{◼ ◻ ◻ ◼} } $ $\substack{ \displaystyle{◼ ◻ ◻ ◼} \cr \displaystyle{◻ ◻ ◼ ◼} \cr \displaystyle{◼ ◼ ◻ ◻} \cr \displaystyle{◻ ◼ ◼ ◻} } $ $\substack{ \displaystyle{◼ ◼ ◻ ◻} \cr \displaystyle{◻ ◼ ◻ ◼} \cr \displaystyle{◻ ◻ ◼ ◼} \cr \displaystyle{◼ ◻ ◼ ◻} } $
An ordering $b_1, b_2, \dots, b_{rn^2}$ of $B$ is Eulerian if for all $i>1$ and for all $j<i$, there is $k<i$ such that $b_i$ and $b_k$ are in a same line $l$, and if $b_i$ and $b_j$ are in a same slice $s$, then $l \subset s$.
Note that the notion of Eulerian ordering is related to the notion of shelling, as explained in this post.
Remark: If $r=n$ then the grid contains black boxes only and the lexicographic ordering is Eulerian.
Question: Has $B$ (satisfying the two above assumptions) an Eulerian ordering if $r \ge 3$?
Remark: The above combination (with $r=2$ and $n = 4$) admits no Eulerian ordering (proved below by brute-force search; a conceptual proof would be useful). Note that any partial Eulerian ordering of it has length at most $11$, see an example below:
Note that the black box marked "?" cannot be added because it shares a slice with the black box n°7 whereas there is no marked black box in this slice which shares a line with "?" (idem for every unmarked black box).
Brute-force search with SAGE
Computation:
sage: %attach SAGE/EulerianGrid.spyx
Compiling ./SAGE/EulerianGrid.spyx...
sage: B=[[1,1,2],[1,1,4],[1,2,1],[1,2,3],[1,3,1],[1,3,2],[1,4,3],[1,4,4],[2,1,1],[2,1,4],[2,2,2],[2,2,4],[2,3,1],[2,3,3],[2,4,2],[2,4,3],[3,1,2],[3,1,3],[3,2,1],[3,2,2],[3,3,3],[3,3,4],[3,4,1],[3,4,4],[4,1,1],[4,1,3],[4,2,3],[4,2,4],[4,3,2],[4,3,4],[4,4,1],[4,4,2]]
sage: %time PartialOrdering(B,[],11)
CPU times: user 29min 4s, sys: 796 ms, total: 29min 5s
Wall time: 29min 27s
Code:
# %attach SAGE/EulerianGrid.spyx
from sage.all import *
cpdef JoinDegree(list L1, list L2):
cdef int i,c
c=0
for i in range(3):
if L1[i]==L2[i]:
c+=1
return c
cpdef IsCollinearList(list l, list L):
cdef list i
if L==[]:
return True
for i in L:
if JoinDegree(l,i)==2:
return True
return False
cpdef PartialOrdering(list L, list P, int A):
cdef int c,cc
cdef list i,j,k,t,LL,PP
if len(P)>A:
print(P)
if L<>[]:
for i in L:
if IsCollinearList(i,P):
cc=0
for j in P:
if JoinDegree(i,j)==1:
c=0
for k in P:
if JoinDegree(i,k)==2 and JoinDegree(j,k)>=1:
c=1
break
if c==0:
cc=1
if cc==0:
LL=[t for t in L]
PP=[t for t in P]
LL.remove(i)
PP.append(i)
if LL<>[]:
PartialOrdering(LL,PP,A)
else:
return PP