Only permutations where every adjacent pair sums to a perfect square count, so we can build the permutation one element at a time and abandon a branch the moment a...