Search code examples
pythongeometrycomputational-geometry

How to approach 'four points, two distance, unique shapes' problem, computationally


Looking for a way to find solutions for this problem computationally (using program) without pen and paper or plotting.

Find all the ways to arrange four points so that only two distances occur between any two points

In other words, how many ways are there to draw four dots on a piece of paper such that whichever two dots you choose, the distance between these two points is one of two values?

Source : https://www.theguardian.com/science/series/alex-bellos-monday-puzzle

Solutions that satisfy

Edit 1: Not looking for the solutions themselves. Looking for the computational approach (formal approach) to arrive at the solution.


Solution

  • These are the only possible complete graphs of four vertices such that the set of edges is partitioned in two subsets. The sizes are (5, 1), (4, 2) and (3, 3).

    enter image description here

    Now the equal distance constraints tell you how the geometry must be adjusted. In particular, triangles of the same color must be equilateral and triangles of two colors must be isoceles.