Brachylog v2, 10 bytes
p.¬{s₂=}∨Ė
Brute-force solution. (This is a function, allowed because the challenge does not say "full program".) It's also mostly a direct translation of the spec (the only real subtlety is that I managed to arrange things so that all the implicit constraints arrived in exactly the right places, thus not needing any extra characters to disambiguate them).
Note that this is a generic algorithm for rearranging any sort of list so that it does not have two touching elements; it can handle string representations of the elements, and it can handle integer codes just as well. So it doesn't really matter how the "Your program must have a way of representing each kind of nut, such as an integer code." requirement from the question is interpreted.
Explanation
p.¬{s₂=}∨Ė
p Find a permutation of {the input}
¬{ } which does not have the following property:
s₂ it contains a pair of adjacent elements
= that are equal
∨ {no constraint on what value the equal elements can have}
. If you find such a permutation, output it.
∨ If no permutation is found, ignore the input and
Ė {output} an empty list