Beispiel #1
0
 /// <summary>
 /// #TODO: Document, Clean
 /// </summary>
 /// <param name="hint"></param>
 /// <param name="progressiveState"></param>
 /// <param name="hintIndex"></param>
 /// <param name="positionIndex"></param>
 /// <returns></returns>
 protected static IEnumerable <CellState[]> GenerateLinePermutations(Hint hint, CellState[] progressiveState, int hintIndex, int positionIndex)
 {
     if (hintIndex >= hint.Length)
     {
         yield return(progressiveState);
     }
     else
     {
         int k = progressiveState.Length - (hint.Occupation(hintIndex + 1) + hint[hintIndex]) - positionIndex;
         for (int i = positionIndex; i < positionIndex + k; i++)
         {
             CellState[] newState = new CellState[progressiveState.Length];
             progressiveState.CopyTo(newState, 0);
             for (int j = 0; j < hint[hintIndex]; ++j)
             {
                 newState[i + j] = CellState.Fill;
             }
             foreach (var t in GenerateLinePermutations(hint, newState, hintIndex + 1, i + hint[hintIndex] + 1))
             {
                 yield return(t);
             }
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// #TODO: Document
 /// </summary>
 /// <param name="hint"></param>
 /// <param name="lineLength"></param>
 /// <returns></returns>
 public static IEnumerable <CellState[]> RowPermutations(Hint hint, int lineLength)
 {
     return(GenerateLinePermutations(hint, new CellState[lineLength], 0, 0));
 }