Ответ может быть очень длинным, но по сути вы добавляете еще одно правило к самой известной проблеме:
высота
The solution is represented by a set D, if for the Cartesian product, D×D, each element ((ik, jk), (il, jl)) either satisfies all of the following rules or fails all of them.
(1) ik ≠ il (not on same column)
(2) jk ≠ jl (not on same row)
(3) ik + jk ≠ il + jl (not on same diagonal)
(4) ik − jk ≠ il − jl (not on same diagonal)
Чтобы сделать это 3d добавьте:
(5) ih ≠ jh (not on the same vertical plane with height h)
https://medium.com/@abhijith0505/the-n-queens-in-3-d-640e20130912