# Genearalisation of previous MSE question regarding password combinatorics in $n$ dimensions

This question caught my atention recently. Most (if not all) of the answers aproached the problem via a brute force attack. Surely there is a more elegant way to deal with this, given the inherent symmetry.

My question is can this be generalised to an $n$ dimensional lattice? Clearly the placement of the nearest neighbour is critical in this problem (ie, it is unclear where $n=5$ in $2$ dimensions would be places in terms of the classical Descatrian coordinate system), but it could also be generalised to $n$ in any dimension. Is this a Hamiltonian path (ie NP hard problem), or can the symmetry be utilised to present a more analytic solution?

Note

If standard MSE policy of questions being self-contained is desired, please note, and I will alter.

• What exactly do you mean by symmetry? – Matt Samuel Dec 2 '15 at 23:50
• @MattSamuel Clearly one vertec needs to be consisered and mutliplied by 4. The same goes of the mid- sides, and the centre is the exception. The problem lies of course in the topological issue of not retracing your steps. – martin Dec 2 '15 at 23:52
• Surely there is a more elegant way to deal with this, given the inherent symmetry. - Surely there is a God, given the inherent order present in the Universe. – Lucian Dec 3 '15 at 2:18
• @Lucien oh, the irony ;) – martin Dec 3 '15 at 2:19