穷举法搞定了, 数据结构:
TBugSide = (
////////////////////////////////////////////////////////////////////////////
// Enumeration defining the heads and tails of the insects in the puzzle.
// Each insect has a different colour.
tbsBlackHead, //this the head of a black bug
tbsBlackTail, //this the tail of a black bug
tbsBlueHead, //this the head of a blue bug
tbsBlueTail, //this the tail of a blue bug
tbsGreenHead, //this the head of a green bug
tbsGreenTail, //this the tail of a green bug
tbsRedHead, //this the head of a red bug
tbsRedTail //this the tail of a red bug
);
TPieceSide = (
////////////////////////////////////////////////////////////////////////////
// Enumeration defining the the 4 sides of each piece which are north, east,
// south, west.
tpsNorth, //the North side
tpsEast, //the east side
tpsSouth, //the south side
tpsWest //the west side
);