/// <summary>
            /// Break the prefix string into moves (a sequence of integer row ids that
            /// will be selected for each column in order).
            /// </summary>
            /// <remarks>
            /// Break the prefix string into moves (a sequence of integer row ids that
            /// will be selected for each column in order). Find all solutions with
            /// that prefix.
            /// </remarks>
            /// <exception cref="System.IO.IOException"/>
            protected override void Map <_T0>(WritableComparable <_T0> key, Text value, Mapper.Context
                                              context)
            {
                prefixString = value;
                StringTokenizer itr = new StringTokenizer(prefixString.ToString(), ",");

                int[] prefix = new int[depth];
                int   idx    = 0;

                while (itr.HasMoreTokens())
                {
                    string num = itr.NextToken();
                    prefix[idx++] = System.Convert.ToInt32(num);
                }
                pent.Solve(prefix);
            }
示例#2
0
        /// <summary>Solve the 6x10 pentomino puzzle.</summary>
        public static void Main(string[] args)
        {
            int       width  = 6;
            int       height = 10;
            Pentomino model  = new Pentomino(width, height);
            IList     splits = model.GetSplits(2);

            for (IEnumerator splitItr = splits.GetEnumerator(); splitItr.HasNext();)
            {
                int[] choices = (int[])splitItr.Next();
                System.Console.Out.Write("split:");
                for (int i = 0; i < choices.Length; ++i)
                {
                    System.Console.Out.Write(" " + choices[i]);
                }
                System.Console.Out.WriteLine();
                System.Console.Out.WriteLine(model.Solve(choices) + " solutions found.");
            }
        }