Communication between arduinos over 4 interchangeable pins

Trying to visualize this. When you say cubic puzzle, I am picturing a rubik's cube, but you mention only 6 to 9 pieces, which is not enough. So, then I am thinking sliding puzzle, but that doesn't use cubes. So, I did a search and found photo puzzles, but couldn't find any example that would work with 6 or 9 pieces.

Do you have a link to a simple example?

The reason I am asking is because math is likely to solve your problem easier than trying to figure out how to communicate over different wires. When I was assuming rubik's cube for example, I was envisioning a way to simply complete a circuit based on position since a single piece is actually limited in the combinations it can be in.

There is likely a much simpler way using truth tables, if I could visualize this properly.