Example #1
0
 public static IEnumerable<Chuzzle> GetVerticalLineChuzzles(int x, ChuzzleType chuzzleType,
     IEnumerable<Chuzzle> chuzzles)
 {
     var enumerable = chuzzles as IList<Chuzzle> ?? chuzzles.ToList();
     var firstChuzzle = enumerable.FirstOrDefault(c => c.Real.x == x && c.Type == chuzzleType);
     if (firstChuzzle != null)
     {
         var secondChuzzle =
             enumerable.FirstOrDefault(
                 c =>
                     c.Type == firstChuzzle.Type &&
                     (c.Current == firstChuzzle.Current.Top || c.Current == firstChuzzle.Current.Bottom));
         if (secondChuzzle != null)
         {
             return new List<Chuzzle> {firstChuzzle, secondChuzzle};
         }
         return new List<Chuzzle> {firstChuzzle};
     }
     return new List<Chuzzle>();
 }
Example #2
0
 public static IEnumerable<Chuzzle> GetHorizontalLineChuzzles(int y, ChuzzleType chuzzleType,
     IEnumerable<Chuzzle> chuzzles)
 {
     var enumerable = chuzzles as IList<Chuzzle> ?? chuzzles.ToList();
     var firstChuzzle = enumerable.FirstOrDefault(x => x.Real.y == y && x.Type == chuzzleType);
     if (firstChuzzle != null)
     {
         var secondChuzzle =
             enumerable.FirstOrDefault(
                 c =>
                     c.Type == firstChuzzle.Type &&
                     (c.Current == firstChuzzle.Current.Left || c.Current == firstChuzzle.Current.Right));
         if (secondChuzzle != null)
         {
             return new List<Chuzzle> {firstChuzzle, secondChuzzle};
         }
         return new List<Chuzzle> {firstChuzzle};
     }
     return new List<Chuzzle>();
 }