A log-cabin quilt is made by sewing strips of fabric in a rectangular spiral. All strips of fabric are
1 inch wide. The first two strips are 1 inch long, the second two strips are 2 inches long, the third
two strips are 3 inches long, and so on. Each new strip is sewn perpendicular to the previous strip in
a counter-clockwise spiral, as shown below:
This quilt is made with nine strips, represented by the characters 'A' through 'I'. The first strip
is labeled 'A', the second strip is labeled 'B', and so on.
You want to design your quilt so that no two adjacent strips are made from the same fabric. Two strips are
adjacent if they share a common side. For example, the 'C' strip in the above picture is adjacent to the 'A',
'B', 'D', 'F', and 'G' strips, and therefore must be a different fabric from each of those five strips.
It turns out that you never need more than four different fabrics to accomplish this goal.
You have four 1-inch wide scraps of different fabrics that you will be cutting into the strips that you need.
You want to know how big a quilt you can
make, as measured by the number of strips in the finished quilt. For example, the above quilt has
nine strips. You will be given a int fabrics containing exactly four elements.
Each element contains the length in inches of a different scrap.