The problem statement contains an image.
In VLSI design it's important to connect certain pairs of points on a circuit using as little wire as possible.
Given an empty circuit board of size N x N, we want to connect the two points A1 and A2
with each other using one wire, and the two points B1 and B2 with each other using another wire.
The wires must go along the horizontal and vertical edges on the grid (see figure), and the two wires may not
share a common vertex.
Create a class ConnectingPoints containing the method shortestWires, which takes an int
N, the number of vertices on one side of the circuit board, and a pair of int[], X and Y,
each containing four elements. Elements 0 and 1 in X and Y contain the coordinates for
A1 and A2, and elements 2 and 3 in X and Y contain the coordinates for
B1 and B2. The method should return the minimum length of wires needed
to connect A1 with A2 and B1 with B2. If it's not
possible to connect the points, return -1 (see example 1).
|