TweetFollow Us on Twitter

Mar 98 Challenge

Volume Number: 14 (1998)
Issue Number: 3
Column Tag: Programmer's Challenge

Programmer's Challenge

by Bob Boonstra, Westford, MA

Help Peter Get Home

Last summer, while he was on his way back to Perth from MacHack, Peter Lewis suggested a challenge based on airline schedules. His idea was to select the quickest route from an origin to a destination, given a schedule of flights between pairs of cities. This month's Challenge is based on Peter's suggestion, but embellished to capture the "probabilistic" nature of airline travel these days.

Your job is to write a routine FindQuickestRoute that will route Peter from his departureAirport to his arrivalAirport in as few simulated flight hours as possible. Peter's trip begins on startDay at startTime. He has a list of airports to which he can fly, and an airlineSchedule of flights between pairs of those airports. The airlineSchedule consists of a flightNumber that will take him from a fromAirport to a toAirport, nominally departing at a scheduledDepartureTime, and nominally taking nominalFlightDuration seconds to get there. The scheduledDepartureTime is expressed in the local time zone of the fromAirport, which is provided as a timeOffset from Universal Time associated with each of the airports. Some of the flights in the airlineSchedule operate only on particular days, described in the operatingDays associated with each flightNumber.

Each of the airports has a minConnectTime, which is the minimum amount of time following one's arrival at the airport before one can catch a connecting flight. This applies to the initial flight, which must be scheduled to leave at least minConnectTime after the startTime of Peter's adventure. Each subsequent connecting leg must also be scheduled to leave at least minConnectTime after the actual arrival time of the preceding leg.

Sounds simple enough so far, right? Except that airplanes seldom depart or arrive on time. So we have introduced a little randomness in our simulated airline operations. The actual departure time of each flight is modeled as a random variable with an exponential distribution, governed by the parameter lambdaDeparture. The duration of each flight is also modeled as an exponential distribution, governed by lambdaDuration. When you decide to take a flight, the callback routine myGetFlightTime will roll the exponential dice for you and return the number of minutes the flight actually took, measured from the scheduledDepartureTime, taking into account the departure delay and the duration delay. A few facts for those whose probability theory is a little rusty: an exponential distribution with parameter t has a probability density function of t*exp(-tx), an expected value of (1/t), and a variance of 1/t2.

The prototype for the code you should write is:

#if defined(__cplusplus)
extern "C" {
#endif

typedef char FlightNum[8],AirportName[64];

typedef enum {
 Sunday=0, Monday, Tuesday, Wednesday, Thursday, Friday, 
 Saturday} DayOfWeek;

typedef struct MyTime {
 long hour;   /* 0-23, 0==midnight */
 long min;    /* 0-59 */
} MyTime;

typedef struct {
 AirportName name;     /* airport name */
 MyTime timeOffset;    /* local time offset relative to Universal Time */
                       /* 0 == Greenwich, {-5,0}==Eastern Time, etc. */
 MyTime minConnectTime;/* minimum time to make a connection at this airport */
} Airport;

typedef struct {
 FlightNum flightNumber;
 AirportName fromAirport;
 AirportName toAirport;
 MyTime scheduledDepartureTime;  /* local departure time from fromAirport */
 MyTime nominalFlightDuration;   /* nominal flight duration */
 float lambdaDeparture;          /* parameter for actual flight departure
                                    (mins) */
 float lambdaDuration;           /* parameter for actual flight duration
                                    (mins) */
 Boolean operatingDays[7];       /* if operatingDays[d], flight valid on 
                                    day d */
} Flight;

typedef long (*GetFlightTime) (
      /* returns actual flight duration from scheduledDepartureTime in minutes */
 FlightNum flightNumber          /* flight number taken */
);

long FindQuickestRoute(          /* return travel time in seconds */
 AirportName departureAirport,   /* origin airport */
 AirportName arrivalAirport,     /* destination airport */
 DayOfWeek startDay,             /* day the adventure begins (local time) */
 MyTime startTime,               /* time the adventure begins (local time) */
 Airport airports[],             /* places to fly from/to */
 long numAirports,               /* number of entries in airports[] */
 Flight airlineSchedule[],       /* flights to choose from */
 long numFlights,                /* number of entries in airlineSchedule[] */
 GetFlightTime myGetFlightTime   /* callback that provides actual flight
                                    duration */
);

#if defined(__cplusplus)
}
#endif

My test code will keep track of the flights you choose in the myGetFlightTime routine. It will ensure that operatingDays and minConnectTime constraints are met, that the fromAirport for travel leg n+1 is the same as the toAirport for travel leg n, etc. Violations of these constraints will result in a 24 hour simulated time penalty.

Test cases will include several trials for each departure/arrival pair to average out randomness. The winner will be the solution that routes Peter to his destinations in the least amount of time, where time is calculated as cumulative simulated travel time plus a penalty of 1 simulated hour for every second of execution time required by your FindQuickestRoute solution.

This will be a native PowerPC Challenge, using the latest CodeWarrior environment. Solutions may be coded in C, C++, or Pascal. Thanks to Peter Lewis for inspiring this Challenge -- he wins two Challenge points for the suggestion.

Three Months Ago Winner

If the number of entries to the December Challenge is any indication, many Programmer's Challenge readers are also avid crossword puzzle-ists. Congratulations to Mat Hostetter (location unknown) for submitting the fastest of 14 entries Clueless Crosswords Challenge. The problem was to solve (or actually, to generate) a crossword puzzle given the pattern of open and blocked cells, along with a dictionary of words from which to choose. The dictionary contained up to ten extra words for each word in the crossword puzzle solution, making multiple solutions were possible.

The evaluation is based on the time required to solve each of five crossword puzzles three times, each time with the dictionary sorted differently. I used each puzzle three times because a number of contestants reported that execution time varied significantly depending on the sort order of the dictionary, a fact that was borne out in my tests. Some of the entries took two orders of magnitude more time to solve a puzzle for one sort order than for the same puzzle with a different sort order. The winning entry exhibited significantly less variability, ranging from a 4% difference for one crossword puzzle to a 63% difference for another puzzle.

Like many of the entries submitted, Mat's solution has a recursive component. To accommodate recursion, I gave each entry 512K of stack space.

The key to efficient solution of this Challenge was propagating the constraints imposed by puzzle squares where an "across" word intersected a "down" word. The style of crossword puzzle provided in the test code and used to evaluate this Challenge contained many blocks of cells that were 4x4 or larger, resulting in many such intersections. Mat uses a set of filter_for_length_N routines to efficiently propagate constraints imposed by the intersections. When reading the modestly commented code, pay particular attention to the create_placements routine used to identify possible word locations, and to the tighten_constraints routine used to eliminate conflicting word placements.

Five of the entries had not solved one or more test cases after ten minutes or more, exceeding my ability to wait for an answer. In these cases, a test time of 10 minutes was assessed.

The table below lists the total execution time in seconds for the fifteen test cases, code size, data size, and programming language for each entry. The number in parentheses after the entrant's name is the total number of Challenge points earned in all Challenges to date prior to this one. The entries marked with an asterisk are those which did not complete one or more test cases in the 10 minutes mentioned above.

Name                    Time   Code      Data  Language
Mat Hostetter           0.37  14196       200  C
Brad Smith              1.36   7532     61835  C
Tom Saxton (12)         1.42   4132         8  C
Jens Martin Bengaard    9.76   4108     16628  C++
Xan Gregg (114)        23.73   4536    224584  C
Randy Boring (73)      74.56   4260     35158  C
Ernst Munter (310)    107.81   5824     16460  C++
Sebastian Maurer (10) 389.23   3968       112  C++
Rainer Brockerhoff    606.03   4609    165577  C
(*) ACC Murphy (34)  2400.29   6528  10212602  Pascal
(*) Mike Miller      2433.70  10052       428  C++
(*) Eric Kenninga    5599.22   6076       188  C++
(*) Steve Wozniac    5925.92   2836        64  C
(*) H.L.             9000.00   6780      1732  C++

Top 20 Contestants

Here are the Top Contestants for the Programmer's Challenge, including everyone who has accumulated more than 10 points during that the past two years. The numbers below include points awarded over the 24 most recent contests, including points earned by this month's entrants.

Rank  Name                Points
 1.   Munter, Ernst          200  
 2.   Boring, Randy           73
 3.   Cooper, Greg            61
 4.   Lewis, Peter            61
 5.   Mallett, Jeff           50
 6.   Nicolle, Ludovic        48
 7.   Murphy, ACC             34
 8.   Gregg, Xan              28
 9.   Antoniewicz, Andy       24
10.   Day, Mark               20
11.   Higgins, Charles        20
12.   Hostetter, Mat          20
13.   Studer, Thomas          20
14.   Gundrum, Eric           15
15.   Hart, Alan              14
16.   O'Connor, Turlough      14
17.   Picao, Miguel Cruz      14

There are three ways to earn points: (1) scoring in the top 5 of any Challenge, (2) being the first person to find a bug in a published winning solution or, (3) being the first person to suggest a Challenge that I use. The points you can win are:

1st place  20 points            5th place  2 points
2nd place  10 points          finding bug  2 points
3rd place  7 points  suggesting Challenge  2 points
4th place  4 points

Here is Mat's winning solution:

Crossword.c
© 1997 Mat Hostetter

#define kMaxSize 32
typedef char Puzzle[kMaxSize][kMaxSize];  /* referenced as [x][y] */

void Crossword(
 Puzzle thePuzzle,    /* return solved puzzle here */
 char *dictionary[],  /* array of words to choose from */
 long puzzleSize,    /* number of rows/cols in puzzle */
 long dictSize        /* number of words in dictionary */
);

/* Program begins here */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Must be at least 32 bits, and ideally exactly 32 bits. */
typedef long letter_mask_t;

typedef struct {
 const char *original_word;
 unsigned char letter[1]; /* variable-sized array of values [1, 26]. */
} move_t;

/* Non-portable hack to compute size of above struct given how many
 * letters it has. It rounds up to sizeof(void *) to guarantee
 * alignment constraints are met. */
#define MOVE_SIZE(n)                  \
 (((sizeof(void *) + (n) + (sizeof(void *) - 1))    \
  / sizeof(void *))                  \
  * sizeof(void *))

#define NEXT_MOVE(m, n) ((move_t *) ((char *) (m) + (n)))

typedef enum {
 CYCLENESS_UNKNOWN,
 IN_CYCLE,
 NOT_IN_CYCLE
} cycleness_t;

typedef struct _placement_t {
 /* number of entries in `move' array. */
 long num_moves;

 /* If this == current_mark, this placement_t is "marked". We use
  * this for things like recursive searches. */
 unsigned long mark;

 /* Number of letters in each entry of the `move' array. */
 unsigned short letters_per_move;
 
 /* Byte size of each element in the `move' array. */
 unsigned short move_size;

 /* Where does this start? */
 unsigned short start_x, start_y;

 /* Direction this heads. */
 unsigned short dx, dy;

 /* Is this partition part of a cyclic dependency? */
 cycleness_t in_cycle;

 /* Totally done with this placement? */
 char done;

 /* Field temporarily used during recursion. */
 long depth;

 /* 1D index into the board where each letter is placed. */
 unsigned long where[kMaxSize]; 
 
 /* Other placements that intersect this one. */
 struct _placement_t *neighbor[kMaxSize + 1]; 
        /* NULL-terminated. */

 /* array of variable-size objects! Don't dereference this array normally. */
 move_t *move;
} placement_t;

/* No -1 so we can save room for NULL at the end. */
#define PLACEMENT_SIZE(n) \
    (sizeof(placement_t) + (n) * sizeof(move_t *))

filter_for_length_1
static void
filter_for_length_1(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(1));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(1));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   m = NEXT_MOVE(m, MOVE_SIZE(1));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
}

filter_for_length_2
static void
filter_for_length_2(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(2));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(2));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   m = NEXT_MOVE(m, MOVE_SIZE(2));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
}

filter_for_length_3
static void
filter_for_length_3(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(3));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(3));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   m = NEXT_MOVE(m, MOVE_SIZE(3));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
}

filter_for_length_4
static void
filter_for_length_4(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(4));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(4));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   m = NEXT_MOVE(m, MOVE_SIZE(4));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
}

filter_for_length_5
static void
filter_for_length_5(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(5));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(5));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   m = NEXT_MOVE(m, MOVE_SIZE(5));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
}

filter_for_length_6
static void
filter_for_length_6(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(6));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(6));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   m = NEXT_MOVE(m, MOVE_SIZE(6));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
}

filter_for_length_7
static void
filter_for_length_7(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(7));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(7));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   m = NEXT_MOVE(m, MOVE_SIZE(7));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
}

filter_for_length_8
static void
filter_for_length_8(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(8));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(8));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   m = NEXT_MOVE(m, MOVE_SIZE(8));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
}

filter_for_length_9
static void
filter_for_length_9(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(9));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(9));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   m = NEXT_MOVE(m, MOVE_SIZE(9));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
}

filter_for_length_10
static void
filter_for_length_10(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(10));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(10));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   m = NEXT_MOVE(m, MOVE_SIZE(10));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
}


filter_for_length_11
static void
filter_for_length_11(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 const letter_mask_t global_mask_10 = 
      letters_allowed[p->where[10]];
 letter_mask_t allowed_by_us_10 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(11));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))
    || !(global_mask_10 & (1 << m->letter[10]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(11));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   allowed_by_us_10 |= 1 << m->letter[10];
   m = NEXT_MOVE(m, MOVE_SIZE(11));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
 allowed_by_us[10] = allowed_by_us_10;
}

filter_for_length_12
static void
filter_for_length_12(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 const letter_mask_t global_mask_10 = 
      letters_allowed[p->where[10]];
 letter_mask_t allowed_by_us_10 = 0;
 const letter_mask_t global_mask_11 = 
      letters_allowed[p->where[11]];
 letter_mask_t allowed_by_us_11 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(12));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))
    || !(global_mask_10 & (1 << m->letter[10]))
    || !(global_mask_11 & (1 << m->letter[11]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(12));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   allowed_by_us_10 |= 1 << m->letter[10];
   allowed_by_us_11 |= 1 << m->letter[11];
   m = NEXT_MOVE(m, MOVE_SIZE(12));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
 allowed_by_us[10] = allowed_by_us_10;
 allowed_by_us[11] = allowed_by_us_11;
}

filter_for_length_13
static void
filter_for_length_13(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 const letter_mask_t global_mask_10 = 
      letters_allowed[p->where[10]];
 letter_mask_t allowed_by_us_10 = 0;
 const letter_mask_t global_mask_11 = 
      letters_allowed[p->where[11]];
 letter_mask_t allowed_by_us_11 = 0;
 const letter_mask_t global_mask_12 = 
      letters_allowed[p->where[12]];
 letter_mask_t allowed_by_us_12 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(13));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))
    || !(global_mask_10 & (1 << m->letter[10]))
    || !(global_mask_11 & (1 << m->letter[11]))
    || !(global_mask_12 & (1 << m->letter[12]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   void *copy4 = ((void **)last)[4];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   ((void **)m)[4] = copy4;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(13));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   allowed_by_us_10 |= 1 << m->letter[10];
   allowed_by_us_11 |= 1 << m->letter[11];
   allowed_by_us_12 |= 1 << m->letter[12];
   m = NEXT_MOVE(m, MOVE_SIZE(13));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
 allowed_by_us[10] = allowed_by_us_10;
 allowed_by_us[11] = allowed_by_us_11;
 allowed_by_us[12] = allowed_by_us_12;
}

filter_for_length_14
static void
filter_for_length_14(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 const letter_mask_t global_mask_10 = 
      letters_allowed[p->where[10]];
 letter_mask_t allowed_by_us_10 = 0;
 const letter_mask_t global_mask_11 = 
      letters_allowed[p->where[11]];
 letter_mask_t allowed_by_us_11 = 0;
 const letter_mask_t global_mask_12 = 
      letters_allowed[p->where[12]];
 letter_mask_t allowed_by_us_12 = 0;
 const letter_mask_t global_mask_13 = 
      letters_allowed[p->where[13]];
 letter_mask_t allowed_by_us_13 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(14));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))
    || !(global_mask_10 & (1 << m->letter[10]))
    || !(global_mask_11 & (1 << m->letter[11]))
    || !(global_mask_12 & (1 << m->letter[12]))
    || !(global_mask_13 & (1 << m->letter[13]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   void *copy4 = ((void **)last)[4];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   ((void **)m)[4] = copy4;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(14));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   allowed_by_us_10 |= 1 << m->letter[10];
   allowed_by_us_11 |= 1 << m->letter[11];
   allowed_by_us_12 |= 1 << m->letter[12];
   allowed_by_us_13 |= 1 << m->letter[13];
   m = NEXT_MOVE(m, MOVE_SIZE(14));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
 allowed_by_us[10] = allowed_by_us_10;
 allowed_by_us[11] = allowed_by_us_11;
 allowed_by_us[12] = allowed_by_us_12;
 allowed_by_us[13] = allowed_by_us_13;
}

filter_for_length_15
static void
filter_for_length_15(placement_t *p, 
      letter_mask_t *letters_allowed,
      letter_mask_t *allowed_by_us)
{
 move_t *m, *last;
 const letter_mask_t global_mask_0 = 
      letters_allowed[p->where[0]];
 letter_mask_t allowed_by_us_0 = 0;
 const letter_mask_t global_mask_1 = 
      letters_allowed[p->where[1]];
 letter_mask_t allowed_by_us_1 = 0;
 const letter_mask_t global_mask_2 = 
      letters_allowed[p->where[2]];
 letter_mask_t allowed_by_us_2 = 0;
 const letter_mask_t global_mask_3 = 
      letters_allowed[p->where[3]];
 letter_mask_t allowed_by_us_3 = 0;
 const letter_mask_t global_mask_4 = 
      letters_allowed[p->where[4]];
 letter_mask_t allowed_by_us_4 = 0;
 const letter_mask_t global_mask_5 = 
      letters_allowed[p->where[5]];
 letter_mask_t allowed_by_us_5 = 0;
 const letter_mask_t global_mask_6 = 
      letters_allowed[p->where[6]];
 letter_mask_t allowed_by_us_6 = 0;
 const letter_mask_t global_mask_7 = 
      letters_allowed[p->where[7]];
 letter_mask_t allowed_by_us_7 = 0;
 const letter_mask_t global_mask_8 = 
      letters_allowed[p->where[8]];
 letter_mask_t allowed_by_us_8 = 0;
 const letter_mask_t global_mask_9 = 
      letters_allowed[p->where[9]];
 letter_mask_t allowed_by_us_9 = 0;
 const letter_mask_t global_mask_10 = 
      letters_allowed[p->where[10]];
 letter_mask_t allowed_by_us_10 = 0;
 const letter_mask_t global_mask_11 = 
      letters_allowed[p->where[11]];
 letter_mask_t allowed_by_us_11 = 0;
 const letter_mask_t global_mask_12 = 
      letters_allowed[p->where[12]];
 letter_mask_t allowed_by_us_12 = 0;
 const letter_mask_t global_mask_13 = 
      letters_allowed[p->where[13]];
 letter_mask_t allowed_by_us_13 = 0;
 const letter_mask_t global_mask_14 = 
      letters_allowed[p->where[14]];
 letter_mask_t allowed_by_us_14 = 0;
 last = (move_t *) ((char *) p->move + 
      (p->num_moves - 1) * MOVE_SIZE(15));
 for (m = p->move; m->original_word != NULL; )
 {
  if (  !(global_mask_0 & (1 << m->letter[0]))
    || !(global_mask_1 & (1 << m->letter[1]))
    || !(global_mask_2 & (1 << m->letter[2]))
    || !(global_mask_3 & (1 << m->letter[3]))
    || !(global_mask_4 & (1 << m->letter[4]))
    || !(global_mask_5 & (1 << m->letter[5]))
    || !(global_mask_6 & (1 << m->letter[6]))
    || !(global_mask_7 & (1 << m->letter[7]))
    || !(global_mask_8 & (1 << m->letter[8]))
    || !(global_mask_9 & (1 << m->letter[9]))
    || !(global_mask_10 & (1 << m->letter[10]))
    || !(global_mask_11 & (1 << m->letter[11]))
    || !(global_mask_12 & (1 << m->letter[12]))
    || !(global_mask_13 & (1 << m->letter[13]))
    || !(global_mask_14 & (1 << m->letter[14]))) {
   void *copy0 = ((void **)last)[0];
   void *copy1 = ((void **)last)[1];
   void *copy2 = ((void **)last)[2];
   void *copy3 = ((void **)last)[3];
   void *copy4 = ((void **)last)[4];
   ((void **)m)[0] = copy0;
   ((void **)m)[1] = copy1;
   ((void **)m)[2] = copy2;
   ((void **)m)[3] = copy3;
   ((void **)m)[4] = copy4;
   last->original_word = NULL;
   --p->num_moves;
   last = NEXT_MOVE(last, -MOVE_SIZE(15));
  } else {
   allowed_by_us_0 |= 1 << m->letter[0];
   allowed_by_us_1 |= 1 << m->letter[1];
   allowed_by_us_2 |= 1 << m->letter[2];
   allowed_by_us_3 |= 1 << m->letter[3];
   allowed_by_us_4 |= 1 << m->letter[4];
   allowed_by_us_5 |= 1 << m->letter[5];
   allowed_by_us_6 |= 1 << m->letter[6];
   allowed_by_us_7 |= 1 << m->letter[7];
   allowed_by_us_8 |= 1 << m->letter[8];
   allowed_by_us_9 |= 1 << m->letter[9];
   allowed_by_us_10 |= 1 << m->letter[10];
   allowed_by_us_11 |= 1 << m->letter[11];
   allowed_by_us_12 |= 1 << m->letter[12];
   allowed_by_us_13 |= 1 << m->letter[13];
   allowed_by_us_14 |= 1 << m->letter[14];
   m = NEXT_MOVE(m, MOVE_SIZE(15));
  }
 }
 allowed_by_us[0] = allowed_by_us_0;
 allowed_by_us[1] = allowed_by_us_1;
 allowed_by_us[2] = allowed_by_us_2;
 allowed_by_us[3] = allowed_by_us_3;
 allowed_by_us[4] = allowed_by_us_4;
 allowed_by_us[5] = allowed_by_us_5;
 allowed_by_us[6] = allowed_by_us_6;
 allowed_by_us[7] = allowed_by_us_7;
 allowed_by_us[8] = allowed_by_us_8;
 allowed_by_us[9] = allowed_by_us_9;
 allowed_by_us[10] = allowed_by_us_10;
 allowed_by_us[11] = allowed_by_us_11;
 allowed_by_us[12] = allowed_by_us_12;
 allowed_by_us[13] = allowed_by_us_13;
 allowed_by_us[14] = allowed_by_us_14;
}

typedef filter_func_t
typedef void (*filter_func_t)(placement_t *, 
      letter_mask_t *, letter_mask_t *);
static const filter_func_t filter_func[16] = { 0,
 filter_for_length_1,
 filter_for_length_2,
 filter_for_length_3,
 filter_for_length_4,
 filter_for_length_5,
 filter_for_length_6,
 filter_for_length_7,
 filter_for_length_8,
 filter_for_length_9,
 filter_for_length_10,
 filter_for_length_11,
 filter_for_length_12,
 filter_for_length_13,
 filter_for_length_14,
 filter_for_length_15,
};


/* Assorted constants, in an enum so debugger knows about them. */
enum {
 /* Bit mask indicating all letters. */
 ALL_LETTERS = (1 << 26) - 1,

 /* Bit mask indicating "this square is not an intersection point
  * so ignore it". */
 NOT_INTERSECTION_POINT = 0x7FFFFFFF,

 /* Empty square in the puzzle. */
 EMPTY_SQUARE = 0
};

static unsigned long current_mark = 1;

#define set_placement_mark(p)   ((p)->mark = current_mark)
#define clear_placement_mark(p)  ((p)->mark = current_mark - 1)
#define placement_is_marked(p)  ((p)->mark == current_mark)
#define clear_all_placement_marks() (++current_mark)


count_num_placements
/* Returns the total number of placements in the puzzle. */
static long
count_num_placements(Puzzle puzzle, long puzzle_size)
{
 long x, y, num_placements = 0;

 /* Horizontal placements. */
 for (y = 0; y < puzzle_size; y++)
  for (x = 0; x < puzzle_size - 1; x++)
   if (puzzle[x][y] == EMPTY_SQUARE && 
              puzzle[x + 1][y] == EMPTY_SQUARE)
    {
     ++num_placements;
     for (x++; x < puzzle_size && 
                        puzzle[x][y] == EMPTY_SQUARE; x++)
      ;
    }

 /* Vertical placements. */
 for (x = 0; x < puzzle_size; x++)
  for (y = 0; y < puzzle_size - 1; y++)
   if (puzzle[x][y] == EMPTY_SQUARE && 
              puzzle[x][y + 1] == EMPTY_SQUARE)
    {
     ++num_placements;
     for (y++; y < puzzle_size && 
                        puzzle[x][y] == EMPTY_SQUARE; y++)
      ;
    }

 return num_placements;
}

identify_placements
static placement_t *
identify_placements(Puzzle puzzle, long puzzle_size, 
      long *num_placements_ptr,
      placement_t *square_to_placement[kMaxSize][kMaxSize][2],
      char interesting_length[kMaxSize + 1])
{
 /* Create an empty map from squares to the placements that intersect. */
 long x, y, num_placements;
 placement_t *p, *placement;

 num_placements = count_num_placements(puzzle, puzzle_size);
 p = placement = (placement_t *) calloc(num_placements, 
                                        sizeof p[0]);
 /* Find all horizontal placements. */
 for (y = 0; y < puzzle_size; y++)
  for (x = 0; x < puzzle_size - 1; x++)
   if (puzzle[x][y] == EMPTY_SQUARE && 
              puzzle[x + 1][y] == EMPTY_SQUARE)
    {
     const long start_x = x;
     p->start_x = x;
     p->start_y = y;
     p->dx = 1;
     p->dy = 0;
     for (; x < puzzle_size && 
                        puzzle[x][y] == EMPTY_SQUARE; x++)
      square_to_placement[x][y][0] = p;
     ++p;
     interesting_length[x - start_x] = 1;
    }

 /* Find all vertical placements. */
 for (x = 0; x < puzzle_size; x++)
  for (y = 0; y < puzzle_size - 1; y++)
   if (puzzle[x][y] == EMPTY_SQUARE && 
              puzzle[x][y + 1] == EMPTY_SQUARE)
    {
     const long start_y = y;
     p->start_x = x;
     p->start_y = y;
     p->dx = 0;
     p->dy = 1;
          for (; y < puzzle_size && puzzle[x][y] ==
               EMPTY_SQUARE; 
                        y++)
      square_to_placement[x][y][1] = p;
     ++p;
     interesting_length[y - start_y] = 1;
    }
 /* assert(p == &placement[num_placements]); */

 *num_placements_ptr = num_placements;
 return placement;
}

intersect_placement_with_global_mask
/* Takes the list of moves allowed by a placement and uses that set
 * to tighten what's globally allowed for the squares it intersects.
 * "Marks" any placements whose word lists are changed as a result. */
static void
intersect_placement_with_global_mask(const placement_t *p,
      letter_mask_t *global_mask)
{
 const unsigned long move_size = p->move_size;
 int i;

 for (i = p->letters_per_move - 1; i >= 0; i--)
  {
   move_t *m;
   letter_mask_t mask = 0, g;

   /* Figure out the union of all letters valid for each square. */
   for (m = p->move; m->original_word != NULL; 
                m = NEXT_MOVE(m, move_size))
    mask |= 1 << m->letter[i];

   g = global_mask[p->where[i]];
   if ((g & mask) != g)
    {
     /* Mark this neighbor as being in need of further refinement,
      * since we have just disallowed some of his moves. */
     set_placement_mark(p->neighbor[i]);

     /* Note the new, tighter restriction on this square. */
     global_mask[p->where[i]] = g & mask;
    }
  }
}

create_ascii_to_letter
/* Creates an array mapping ASCII letter values to numbers 0-25. */
static void
create_ascii_to_letter(unsigned char ascii_to_letter[256])
{
 int let;
 memset(ascii_to_letter, 0, 256);
 for (let = 0; let < 26; let++)
  ascii_to_letter['a' + let] = 
          ascii_to_letter['A' + let] = let;
}

partition_words_by_length
static void
partition_words_by_length(char *dictionary[], long dict_size,
      const char interesting_length[kMaxSize + 1],
      const char **words_of_length[kMaxSize + 1],
      long num_words_of_length[kMaxSize + 1],
      void **mem_to_free_on_cleanup)
{
 long num_words_left[kMaxSize + 1], num_useful_words, 
          i, j, w, k;
 const char **r;
 void *raw_words_mem;
 
 /* Figure out how many words there are of each length. */
 for (i = 0; i <= kMaxSize; i++)
  num_words_of_length[i] = 0;
 num_useful_words = 0;
 for (w = 0; w < dict_size; w++)
  {
   size_t len = strlen(dictionary[w]);
   if (len <= kMaxSize && interesting_length[len])
    {
     ++num_words_of_length[len];
     ++num_useful_words;
    }
  }

 /* Allocate room for a pointer vector for each word length.
  * We'll just put all of the pointer vectors together into
  * one big block of memory, separated by a NULL pointer. */
 raw_words_mem = 
      malloc((num_useful_words + kMaxSize + 1) * sizeof r[0]);
 r = (const char **) raw_words_mem;
 for (k = 0; k <= kMaxSize; k++)
  {
   const long num_words_of_this_length = 
            num_words_of_length[k];
   words_of_length[k] = r;
   r[num_words_of_this_length] = NULL;
   r += num_words_of_this_length + 1;
           /* leave room for terminating NULL */
  }

 /* Note the words of each length. */
 memcpy(num_words_left, num_words_of_length, 
        sizeof num_words_left);
 for (j = 0; j < dict_size; j++)
  {
   size_t len = strlen(dictionary[j]);
   if (len <= kMaxSize && interesting_length[len])
    words_of_length[len][--num_words_left[len]] = 
                  dictionary[j];
  }

 /* Report the block of memory to free when done. */
 *mem_to_free_on_cleanup = raw_words_mem;
}

tighten_constraints
static int
tighten_constraints(placement_t *placement, long num_placements,
      letter_mask_t *letters_allowed, int do_acyclic)
{
 placement_t **orig_stack, **stack, *p;
 long n;

 stack = orig_stack = malloc((num_placements + 1) * 
        sizeof orig_stack[0]);
 *stack++ = NULL;

 /* On entry, we've marked every placement that needs to be explored
  * further, so push those on the stack. */
 for (n = num_placements - 1; n >= 0; n--)
  {
   placement_t *t = &placement[n];
   if (placement_is_marked(t))
    *stack++ = t;
  }

 while ((p = *--stack) != NULL)
  {
   letter_mask_t allowed_by_us[kMaxSize];
   long i;
   
   if (p->done || 
              (!do_acyclic && p->in_cycle == NOT_IN_CYCLE))
    continue;

   if (p->letters_per_move < 
                  sizeof filter_func / sizeof filter_func[0])
    (*filter_func[p->letters_per_move])(p, 
                      letters_allowed, allowed_by_us);
   else
    {
     letter_mask_t global_mask[kMaxSize];
     long i, move_size;
     move_t *m, *last;
    
     move_size = p->move_size;
     memset(allowed_by_us, 0, sizeof allowed_by_us);
    
     /* For speed, stash globally allowed letters in linear array. */
     for (i = 0; i < p->letters_per_move; i++)
      global_mask[i] = letters_allowed[p->where[i]];
    
     /* Loop through all words here, discarding illegal words and
      * accruing a new union mask. */
     last = (move_t *) ((char *) p->move + 
                  (p->num_moves - 1) * p->move_size);
     for (m = p->move; m->original_word != NULL; )
      {
       long j;
     
       /* See if word is legal. */
       for (j = p->letters_per_move - 1; j >= 0; j--)
        if (!(global_mask[j] & (1 << m->letter[j])))
         break;
       
       if (j < 0)
        {
         /* It's legal. Note the possible letters and move on. */
        long k;
        for (k = p->letters_per_move - 1; k >= 0; k--)
          allowed_by_us[k] |= 1 << m->letter[k];
         m = NEXT_MOVE(m, move_size);
        }
       else
        {
         /* It's illegal. Delete this move by replacing it with
          * the last move in the list. Profiling shows this is
          * a hotspot, so inline a memcpy using our knowledge
          * about what moves look like. */
         char *from, *to;
         long ctr;
         from = (char *) last;
         to = (char *) m;
         for (ctr = move_size; 
                          (ctr -= sizeof(void *)) >= 0; )
          *(void **)(to + ctr) = 
                                *(void **)(from + ctr);
         
         last->original_word = NULL;
         --p->num_moves;
         last = NEXT_MOVE(last, -move_size);
        }
      }
    }

   if (p->num_moves == 0)
    {
     /* No moves --> no solution. Quit now! */
     free(orig_stack);
     return 0;
    }

   /* Propagate our constraints to the global grid. If we actually
    * change anything, note that we need to recompute the valid
    * words list for whomever intersects the newly tightened square. */
   for (i = p->letters_per_move - 1; i >= 0; i--)
    {
     letter_mask_t g = letters_allowed[p->where[i]];
     if ((g & allowed_by_us[i]) != g)
      {
       placement_t *nbr;
       letters_allowed[p->where[i]] = 
                      g & allowed_by_us[i];
       nbr = p->neighbor[i];
       if (!placement_is_marked(nbr))
        {
         *stack++ = nbr;
         set_placement_mark(nbr);
        }
      }
    }

   clear_placement_mark(p);
  }

 free(orig_stack);
 return 1;
}

place_word
static void
place_word(Puzzle puzzle, int x, int y, int dx, int dy, 
          const char *word)
{
 for (; *word; word++)
  {
   puzzle[x][y] = *word;
   x += dx;
   y += dy;
  }
}

place_move
static void
place_move(Puzzle puzzle, placement_t *p, move_t *m)
{
 place_word(puzzle, p->start_x, p->start_y, 
            p->dx, p->dy, m->original_word);
}

solve_trivial_placements
/* Go ahead and fill in every placement where there's only one choice. */
static void
solve_trivial_placements(Puzzle puzzle, placement_t *placement,
        long num_placements)
{
 long i;

 /* Go ahead and make any move where there's only one choice. */
 for (i = 0; i < num_placements; i++)
  {
   placement_t *p = &placement[i];
   if (p->num_moves == 1)
    {
     place_move(puzzle, p, &p->move[0]);
     free(placement[i].move);
     placement[i].move = NULL;
     p->num_moves = 0;
     p->done = 1;
    }
  }
}

create_placements
static placement_t *
create_placements(Puzzle puzzle, long puzzle_size,
      char *dictionary[], long dict_size,
      letter_mask_t letters_allowed[kMaxSize * kMaxSize],
      long *letters_allowed_size_ptr,
      long *num_placements_ptr)
{
 /* Do we care about words of length n? */
 char interesting_length[kMaxSize + 1];
 long n, num_placements;
 placement_t *placement;
 const char **words_of_length[kMaxSize + 1];
 long num_words_of_length[kMaxSize + 1];
 move_t **hash_table = NULL;
 unsigned long max_hash_table_size = 0;
 void *mem_to_free;

 /* Maps [A-Za-z] to the numbers 1-26, zero for all others. */
 unsigned char ascii_to_letter[256];

 /* Maps intersection squares to unique contiguous numbers.
  * Undefined garbage for non-intersection squares. */
 unsigned long square_to_packed_linear[kMaxSize][kMaxSize];
 unsigned long num_packed_linears = 0;

 /* Gives us the up to two placements that intersect the given square. */
 placement_t *square_to_placement[kMaxSize][kMaxSize][2];

 /* Initialize assorted arrays. */
 memset(square_to_placement, 0, sizeof square_to_placement);
 memset(interesting_length, 0, sizeof interesting_length);

 create_ascii_to_letter(ascii_to_letter);

 /* Create all of the placement structs, etc. */
 placement = identify_placements(puzzle, puzzle_size, 
      &num_placements, square_to_placement, interesting_length);

 /* Figure out all of the words of the various lengths we want. */
 partition_words_by_length(dictionary, dict_size, 
      interesting_length, words_of_length, num_words_of_length,
      &mem_to_free);

 /* Loop through each partition and set up its neighbors and move list,
  * and reflect our move list on the global state. */
 for (n = 0; n < num_placements; n++)
  {
   placement_t *t = &placement[n];
   long num_intersect_squares = 0;
   long x, y, dx, dy, length;
   letter_mask_t mask[kMaxSize];

   /* If anyone marked us as needing further refinement, clear it
    * since we're going to do that refinement now. */
   clear_placement_mark(t);

   dx = t->dx;
   dy = t->dy;

   for (x = t->start_x, y = t->start_y, length = 0;
      x < puzzle_size && y < puzzle_size && 
                      puzzle[x][y] == EMPTY_SQUARE;
      x += dx, y += dy, length++)
    {
     placement_t *p0 = square_to_placement[x][y][0];
     placement_t *nbr;

     /* default to all letters being allowed for this square. */
     mask[length] = NOT_INTERSECTION_POINT;

     if (p0 != NULL && p0 != t)
      nbr = p0;
     else
      {
       placement_t *p1 = square_to_placement[x][y][1];
       if (p1 != NULL && p1 != t)
        nbr = p1;
       else
        nbr = NULL;
      }
     if (nbr != NULL)
      {
       /* If we are the first partition to visit this intersect
        * point (i.e. this neighbor hasn't been processed) then
        * add this square to the global list of interesting
        * squares. */
       if (nbr->letters_per_move != 0)
        mask[length] = 
                  letters_allowed
                  [square_to_packed_linear[x][y]];
       else
        {
          mask[length] = ALL_LETTERS;
         letters_allowed[num_packed_linears] = 
                            ALL_LETTERS;
         square_to_packed_linear[x][y] = 
                            num_packed_linears++;
        }

       /* We intersected some other placement here. This means we
        * care about this square. */
       t->neighbor[num_intersect_squares] = nbr;
       t->where[num_intersect_squares] = 
                      square_to_packed_linear[x][y];
       num_intersect_squares++;
      }
    }

   t->letters_per_move = num_intersect_squares;
   t->move_size = MOVE_SIZE(num_intersect_squares);

   if (t->letters_per_move == 0)
    {
     /* Plug in anything that fits. */
     if (num_words_of_length[length] == 0)
      {
       /* No solution! */
       goto done;
      }
     place_word(puzzle, t->start_x, t->start_y, 
                  t->dx, t->dy, words_of_length[length][0]);
     t->done = 1;
     t->num_moves = 0;
     t->move = NULL;
     continue;
    }

   /* Create all the moves for this placement. */
     t->move = (move_t *) malloc((num_words_of_length[length]+1)
                 * MOVE_SIZE(length));

   {
    const char **w;
    move_t *m = t->move;
    unsigned long hash_table_size;

    hash_table_size = num_words_of_length[length] * 3 + 16;
    if (hash_table_size > max_hash_table_size)
     {
      free(hash_table);
      max_hash_table_size = hash_table_size;
      hash_table = calloc(max_hash_table_size, 
                    sizeof hash_table[0]);
     }
    else
     memset(hash_table, 0, hash_table_size * 
                    sizeof hash_table[0]);

    for (w = words_of_length[length]; *w; w++)
     {
      const char *s = *w;
      unsigned long hash;
      long ix, out;

      hash = 1;
      for (ix = out = 0; s[ix] != '\0'; ix++)
       if (mask[ix] != NOT_INTERSECTION_POINT)
        {
         int letter = 
                    ascii_to_letter[(unsigned char) s[ix]];
         if ((mask[ix] & (1 << letter)) == 0)
          break;
         hash = (hash * 26) + letter;
         m->letter[out++] = letter;
        }

      /* If we made it all the way to the end without failing,
       * then add this word to the list. */
      if (s[ix] == '\0')
       {
        const move_t *test_move;
        long j;

        hash %= hash_table_size;

       while ((test_move = hash_table[hash]) != NULL)
        {
        for (j = t->letters_per_move - 1; j>=0; j--)
          if (test_move->letter[j] != m->letter[j])
            break;
          if (j < 0)
           break;
          if (++hash >= hash_table_size)
           hash -= hash_table_size;
         }
        if (test_move == NULL)
         {
          hash_table[hash] = m;
          m->original_word = *w;
          ++t->num_moves;
          m = NEXT_MOVE(m, t->move_size);
         }
       }
     }

    /* Terminate our list with a NULL pointer. */
    m->original_word = NULL;
   }

   /* Compute global implications of the legal words here. */
   intersect_placement_with_global_mask(t, letters_allowed);
  }

 solve_trivial_placements(puzzle, placement, num_placements);

done:
 /* We don't need this memory any more, so free it. */
 free(hash_table);
 free(mem_to_free);

 /* Recursively propagate around constraints. */
 tighten_constraints(placement, num_placements, 
          letters_allowed, 1);

 *letters_allowed_size_ptr = num_packed_linears;
 *num_placements_ptr = num_placements;
 return placement;
}

partition_aux
/* Recursive helper function for `partition_and_mark_cycles'. */
static long
partition_aux(placement_t *p, placement_t ***partition, 
      placement_t *parent, long depth)
{
 placement_t **nbrs, *nbr;
 long retval = depth;

 /* Add this placement to our partition. */
 set_placement_mark(p);
 p->depth = depth;
 p->in_cycle = NOT_IN_CYCLE;
 if (!p->done)
  {
   **partition = p;
   ++*partition;

   for (nbrs = p->neighbor; (nbr = *nbrs) != NULL; nbrs++)
    {
     long x;
     
     if (nbr == parent)
      continue;
     
     if (placement_is_marked(nbr))
      x = nbr->depth;
     else
      x = partition_aux(nbr, partition, p, depth + 1);
     if (x <= retval)
      {
       p->in_cycle = IN_CYCLE;
       retval = x;
      }
    }
  }

 return (p->in_cycle == IN_CYCLE) ? retval : 10000000;
}

partition_and_mark_cycles
/* Store all non-solved placements reachable from root that are part of
 * some cycle into partition. */
static long
partition_and_mark_cycles(placement_t *root, 
      placement_t **partition)
{
 placement_t **end_partition, **in, **out, *p;

 /* Put everything in the partition into the array, and mark each
  * that's part of a cycle. */
 end_partition = partition;
 clear_all_placement_marks();
 partition_aux(root, &end_partition, NULL, 1);
 *end_partition = NULL;

 /* Remove everything that's not part of a cycle. */
 for (in = out = partition; (p = *in) != 0; in++)
  if (p->in_cycle == IN_CYCLE)
   *out++ = p;
 *out = NULL;

 return out - partition;
}

solve_partition
/* Tries to solve a partition. Returns true on success. */
static int
solve_partition(Puzzle puzzle, placement_t **partition, 
      long partition_size, letter_mask_t *letters_allowed, 
      long letters_allowed_size, placement_t *all_placements, 
      long all_placements_size, placement_t *start)
{
 placement_t *p, *most_popular;
 move_t **backup_move, *m;
 long *backup_num_moves, i;
 letter_mask_t *backup_letters_allowed;
 placement_t **new_partition;
 int success = 0;
 long bla_size;
 long move_size;

 /* Make a backup copy of our letters_allowed array. */
 bla_size = letters_allowed_size * 
          sizeof backup_letters_allowed[0];
 backup_letters_allowed = malloc(bla_size);
 memcpy(backup_letters_allowed, letters_allowed, bla_size);
 
 /* Make backup copies of our move lists. */
 backup_move = malloc(partition_size * sizeof backup_move[0]);
 backup_num_moves = 
      malloc(partition_size * sizeof backup_num_moves[0]);

 /* Allocate room to hold this. */
 new_partition = 
  malloc((all_placements_size + 1) * sizeof new_partition[0]);

 p = most_popular = NULL;
 
 for (i = 0; i < partition_size; i++)
  {
   placement_t *q = partition[i];
   long size;

   backup_num_moves[i] = q->num_moves;
   size = (q->num_moves + 1) * q->move_size;
   backup_move[i] = malloc(size);
   memcpy(backup_move[i], q->move, size);

   if (q == start)
    p = q;
   else if (most_popular == NULL
        || q->letters_per_move > 
                            most_popular->letters_per_move)
    most_popular = q;
  }

 if (p == NULL)
  p = most_popular;

 /* Hypothetically lay down this move. */
 move_size = p->move_size;
 for (m = p->move; m->original_word; 
              m = NEXT_MOVE(m, move_size))
  {
   long r;
   
   /* Actually lay this move down on the board. */
   place_move(puzzle, p, m);

   /* Remember that this placement is "done". */
   p->done = 1;

   /* Tighten grid and update all neighbors who may care. */
   clear_all_placement_marks();
   for (r = p->letters_per_move - 1; r >= 0; r--)
    {
     letter_mask_t g = letters_allowed[p->where[r]];
     letter_mask_t mask = 1 << m->letter[r];
     if (g != mask)
      {
       letters_allowed[p->where[r]] = mask;
       set_placement_mark(p->neighbor[r]);
      }
    }

   /* Propagate constraints and check for contradiction. */
   if (!tighten_constraints(all_placements, 
            all_placements_size, letters_allowed, 0))
    goto failed;
   
   {
    placement_t **nbrs, *nbr;

    /* No contradiction yet, so try our children. */
    for (nbrs = p->neighbor; (nbr = *nbrs) != 0; nbrs++)
    {
     long new_partition_size;
     new_partition_size = 
              partition_and_mark_cycles(nbr, new_partition);
     if (new_partition_size > 0 && 
                !solve_partition(puzzle, new_partition,
                      new_partition_size, letters_allowed, 
                      letters_allowed_size, all_placements, 
                      all_placements_size, nbr))
      goto failed;
    }
   }

   /* Woohoo! We did it! */
   success = 1;
   break;

   /* This didn't work, so restore state. */
  failed:
   p->done = 0;
   for (r = 0; r < partition_size; r++)
    {
     placement_t *q = partition[r];
     q->num_moves = backup_num_moves[r];
     /* FIXME - don't actually need to copy on the last pass...
      * just assign pointer to backup memory and free the bad copy. */
     memcpy(q->move, backup_move[r], 
                        (q->num_moves + 1) * q->move_size);
    }
   memcpy(letters_allowed, backup_letters_allowed,
       letters_allowed_size * sizeof letters_allowed[0]);
  }

 /* Housecleaning. */
 free(new_partition);
 free(backup_letters_allowed);
 for (i = 0; i < partition_size; i++)
  free(backup_move[i]);
 free(backup_num_moves);
 free(backup_move);

 return success;
}


solve_acyclic_aux
static void
solve_acyclic_aux(Puzzle puzzle, placement_t *p,
         letter_mask_t *letters_allowed)
{
 /* Find any legal move and make it. */
 move_t *m;
 long move_size, loop_start;

 if (p->done)
  return;
 
 move_size = p->move_size;
 loop_start = p->letters_per_move - 1;

 for (m = p->move; m->original_word; 
                  m = NEXT_MOVE(m, move_size))
  {
   long k;
   for (k = loop_start; k >= 0; k--)
    if (!(letters_allowed[p->where[k]] & 
                            (1 << m->letter[k])))
     break;
   if (k < 0)
    {
     long j;
     
     /* Make the move. */
     place_move(puzzle, p, m);
     
     /* Tighten up the board for everyone else. */
     for (j = loop_start; j >= 0; j--)
      letters_allowed[p->where[j]] = 1 << m->letter[j];

     p->done = 1;

     /* Flood out to our neighbors and do them too. */
     for (j = loop_start; j >= 0; j--)
      solve_acyclic_aux(puzzle, p->neighbor[j], 
                    letters_allowed);

     /* Stop looking for a word. */
     break;
    }
  }
}

solve_acyclic_stragglers
/* The main algorithm guarantees we solve things that are part of
 * cycles but not those things which are not part of cycles, because
 * they are utterly trivial given the information we've computed.
 * This solves those last acyclic pieces. */
static void
solve_acyclic_stragglers(Puzzle puzzle,
    placement_t *placement, long num_placements,
    letter_mask_t *letters_allowed)
{
 long i;
 for (i = 0; i < num_placements; i++)
  {
   placement_t *p = &placement[i];
   if (!p->done && p->num_moves > 0)
    solve_acyclic_aux(puzzle, p, letters_allowed);
  }
}


Crossword
void Crossword(
 Puzzle thePuzzle,    /* return solved puzzle here */
 char *dictionary[],  /* array of words to choose from */
 long puzzleSize,    /* number of rows/cols in puzzle */
 long dictSize        /* number of words in dictionary */
)
{
 letter_mask_t letters_allowed[kMaxSize * kMaxSize];
 long num_placements, i, letters_allowed_size;
 placement_t *placement, **partition;
 int success = 1;

 /* Create our placement structures. */
 placement = create_placements(thePuzzle, puzzleSize, 
      dictionary, dictSize, letters_allowed, 
      &letters_allowed_size, &num_placements);

 /* Find disjoint portions of the graph and solve them. */
 partition = malloc((num_placements + 1) * sizeof partition[0]);
 for (i = 0; i < num_placements; i++)
  {
   placement_t *p = &placement[i];
   if (p->num_moves > 0 && p->in_cycle == CYCLENESS_UNKNOWN)
    {
     long partition_size = 
                    partition_and_mark_cycles(p, partition);
     if (partition_size > 0)
      success &= solve_partition(thePuzzle, partition, 
                    partition_size, letters_allowed, 
                    letters_allowed_size, placement, 
                    num_placements, NULL);
    }
  }

 if (success)
  {
   /* Recompute all constraints for everyone not yet solved. */
   for (i = 0; i < num_placements; i++)
    set_placement_mark(&placement[i]);
   tighten_constraints(placement, num_placements, 
                letters_allowed, 1);
   
   /* Go through and solve them. */
   solve_acyclic_stragglers(thePuzzle, placement, 
                num_placements, letters_allowed);
  }
 
 /* House cleaning. */
 free(partition);
 for (i = 0; i < num_placements; i++)
  free(placement[i].move);
 free(placement);
}
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Paperless 3.0.6 - $69.95
Paperless is a digital documents manager. Remember when everyone talked about how we would soon be a paperless society? Now it seems like we use paper more than ever. Let's face it - we need and we... Read more
BetterTouchTool 3.141 - Customize multi-...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom)... Read more
TextMate 2.0.rc.29 - Code/markup editor...
TextMate is a versatile plain text editor with a unique and innovative feature set which caused it to win an Apple Design Award for Best Mac OS X Developer Tool in August 2006 A rapidly growing... Read more
Little Snitch 4.4.1 - Alerts you about o...
Little Snitch gives you control over your private outgoing data. Track background activity As soon as your computer connects to the Internet, applications often have permission to send any... Read more
Little Snitch 4.4 - Alerts you about out...
Little Snitch gives you control over your private outgoing data. Track background activity As soon as your computer connects to the Internet, applications often have permission to send any... Read more
MPlayer OSX Extended 16 - Multimedia pla...
MPlayer OSX Extended is the future of MPlayer OSX. Leveraging the power of the MPlayer and FFmpeg open source projects, MPlayer OSX Extended aims to deliver a powerful, functional and no frills video... Read more
Google Chrome 75.0.3770.142 - Modern and...
Google Chrome is a Web browser by Google, created to be a modern platform for Web pages and applications. It utilizes very fast loading of Web pages and has a V8 engine, which is a custom built... Read more
Notability 4.0.4 - Note-taking and annot...
Notability is a powerful note-taker to annotate documents, sketch ideas, record lectures, take notes and more. It combines, typing, handwriting, audio recording, and photos so you can create notes... Read more
ffWorks 1.3.1 - Convert multimedia files...
ffWorks, focused on simplicity, brings a fresh approach to the use of FFmpeg, allowing you to create ultra-high-quality movies without the need to write a single line of code on the command-line.... Read more
EtreCheck Pro 6.0.2 - For troubleshootin...
EtreCheck is an app that displays the important details of your system configuration and allow you to copy that information to the Clipboard. It is meant to be used with Apple Support Communities to... Read more

Latest Forum Discussions

See All

TEPPEN guide - Tips and tricks for new p...
TEPPEN is a wild game that nobody asked for, but I’m sure glad it exists. Who would’ve thought that a CCG featuring Capcom characters could be so cool and weird? In case you’re not completely sure what TEPPEN is, make sure to check out our review... | Read more »
Dr. Mario World guide - Other games that...
We now live in a post-Dr. Mario World world, and I gotta say, things don’t feel too different. Nintendo continues to squirt out bad games on phones, causing all but the most stalwart fans of mobile games to question why they even bother... | Read more »
Strategy RPG Brown Dust introduces its b...
Epic turn-based RPG Brown Dust is set to turn 500 days old next week, and to celebrate, Neowiz has just unveiled its biggest and most exciting update yet, offering a host of new rewards, increased gacha rates, and a brand new feature that will... | Read more »
Dr. Mario World is yet another disappoin...
As soon as I booted up Dr. Mario World, I knew I wasn’t going to have fun with it. Nintendo’s record on phones thus far has been pretty spotty, with things trending downward as of late. [Read more] | Read more »
Retro Space Shooter P.3 is now available...
Shoot-em-ups tend to be a dime a dozen on the App Store, but every so often you come across one gem that aims to shake up the genre in a unique way. Developer Devjgame’s P.3 is the latest game seeking to do so this, working as a love letter to the... | Read more »
Void Tyrant guide - Guildins guide
I’ve still been putting a lot of time into Void Tyrant since it officially released last week, and it’s surprising how much stuff there is to uncover in such a simple-looking game. Just toray, I finished spending my Guildins on all available... | Read more »
Tactical RPG Brown Dust celebrates the s...
Neowiz is set to celebrate the summer by launching a 2-month long festival in its smash-hit RPG Brown Dust. The event kicks off today, and it’s divided into 4 parts, each of which will last two weeks. Brown Dust is all about collecting, upgrading,... | Read more »
Flappy Royale is an incredibly clever ta...
I spent the better part of my weekend playing Flappy Royale. I didn’t necessarily want to. I just felt like I had to. It’s a hypnotic experience that’s way too easy to just keep playing. | Read more »
Void Tyrant guide - General tips and tri...
Void Tyrant is a card-based dungeon-crawler that doesn’t fit in the mold of other games in the genre. Between the Blackjack-style combat and strange gear system alone, you’re left to your own devices to figure out how best to use everything to your... | Read more »
Webzen’s latest RPG First Hero is offici...
You might be busy sending your hulking Dark Knight into the midst of battle in Webzen’s other recent release: the long-anticipated MU Origin 2. But for something a little different, the South Korean publisher has launched First Hero. Released today... | Read more »

Price Scanner via MacPrices.net

Amazon drops prices, now offers clearance 13″...
Amazon has new dropped prices on clearance 13″ 2.3GHz Dual-Core non-Touch Bar MacBook Pros by $200 off Apple’s original MSRP, with prices now available starting at $1099. Shipping is free. Be sure to... Read more
2018 15″ MacBook Pros now on sale for $500 of...
Amazon has dropped prices on select clearance 2018 15″ 6-Core MacBook Pros to $500 off Apple’s original MSRP. Prices now start at $1899 shipped: – 2018 15″ 2.2GHz Touch Bar MacBook Pro Silver: $1899.... Read more
Price drop! Clearance 12″ 1.2GHz Silver MacBo...
Amazon has dropped their price on the recently-discontinued 12″ 1.2GHz Silver MacBook to $849.99 shipped. That’s $450 off Apple’s original MSRP for this model, and it’s the cheapest price available... Read more
Apple’s 21″ 3.0GHz 4K iMac drops to only $936...
Abt Electronics has dropped their price on clearance, previous-generation 21″ 3.0GHz 4K iMacs to only $936 shipped. That’s $363 off Apple’s original MSRP, and it’s the cheapest price we’ve seen so... Read more
Amazon’s Prime Day savings on Apple 11″ iPad...
Amazon has new 2018 Apple 11″ iPad Pros in stock today and on sale for up to $250 off Apple’s MSRP as part of their Prime Day sale (but Prime membership is NOT required for these savings). These are... Read more
Prime Day Apple iPhone deal: $100 off all iPh...
Boost Mobile is offering Apple’s new 2018 iPhone Xr, iPhone Xs, and Xs Max for $100 off MSRP. Their discount reduces the cost of an Xs to $899 for the 64GB models and $999 for the 64GB Xs Max. Price... Read more
Clearance 13″ 2.3GHz Dual-Core MacBook Pros a...
Focus Camera has clearance 2017 13″ 2.3GHz/128GB non-Touch Bar Dual-Core MacBook Pros on sale for $169 off Apple’s original MSRP. Shipping is free. Focus charges sales tax for NY & NJ residents... Read more
Amazon Prime Day deal: 9.7″ Apple iPads for $...
Amazon is offering new 9.7″ WiFi iPads with Apple Pencil support for $80-$100 off MSRP as part of their Prime Day sale, starting at only $249. These are the same iPads found in Apple’s retail and... Read more
Amazon Prime Day deal: 10% (up to $20) off Ap...
Amazon is offering discounts on new 2019 Apple AirPods ranging up to $20 (10%) off MSRP as part of their Prime Day sales. Shipping is free: – AirPods with Charging Case: $144.99 $15 off MSRP –... Read more
Amazon Prime Day deal: $50-$80 off Apple Watc...
Amazon has Apple Watch Series 4 and Series 3 models on sale for $50-$80 off Apple’s MSRP as part of their Prime Day deals with prices starting at only $199. Choose Amazon as the seller rather than a... Read more

Jobs Board

*Apple* Graders/Inspectors (Seasonal/Hourly/...
…requirements. #COVAentryleveljobs ## Minimum Qualifications Some knowledge of agricultural and/or the apple industry is helpful as well as the ability to comprehend, Read more
Best Buy *Apple* Computing Master - Best Bu...
**710003BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Location Number:** 000171-Winchester Road-Store **Job Description:** Read more
Best Buy *Apple* Computing Master - Best Bu...
**709786BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Location Number:** 000430-Orange Park-Store **Job Description:** **What does a Read more
Geek Squad *Apple* Master Consultation Agen...
**709918BR** **Job Title:** Geek Squad Apple Master Consultation Agent **Job Category:** Services/Installation/Repair **Location Number:** 000106-Palmdale-Store Read more
*Apple* Systems Architect/Engineer, Vice Pre...
…its vision to be the world's most trusted financial group. **Summary:** Apple Systems Architect/Engineer with strong knowledge of products and services related to Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.