This was yet another challenge brought to me by my lovely roommates. They had their ownsolutions, but I wanted to visualise it in 3D.
The question, originally asked by@anniek_p on twitter, sounds simple in nature, what does an order 4 permutohedron look like?
According towikipedia,the permutohedron of order n is an (n − 1)-dimensional polytope embedded in an n-dimensional space. Its vertex coordinates are the permutations of the first n natural numbers. The edges are the shortest possible connections between these points. Two permutations connected by an edge differ in two places, and the numbers on these places are neighbors.
For example
The permutations of 123 are 123, 132,213, 231, 312 and 321
And 123 is a neighbor of 132
See the solution below for values of n between 1 and 6. You can change the value for n with the input below Technically the code works for all n >= 1 but it will max our your browser's CPU pretty fast.
You can also toggle link colors, whereby links between nodes which have the same first number eg. 123 and 132 get the same color. This should help you identify the solutions forn-1 in the solution for n