public static List <PackedItem> WithIncluded(this List <PackedItem> list, PackedItem item)
        {
            var list2 = list.ToList();

            list2.Add(item);
            return(list2);
        }
            private static bool Contains(PackedItem item, string[,] array)
            {
                int rows    = array.GetLength(0);
                int columns = array.GetLength(1);

                int matchedCount = 0;

                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < columns; j++)
                    {
                        string value = array[i, j];
                        if (value == item.Value)
                        {
                            matchedCount++;
                            if (matchedCount == item.Count)
                            {
                                return(true);
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            matchedCount = 0;
                        }
                    }
                }

                return(false);
            }
        private static bool HasAdjacent(List <PackedItem> taken)
        {
            PackedItem previous = null;

            foreach (var item in taken)
            {
                if (previous != null)
                {
                    if (previous.Value == item.Value)
                    {
                        return(true);
                    }
                }
                previous = item;
            }
            return(false);
        }
 private static bool AreEqual(PackedItem a, PackedItem b)
 {
     return(a.Count == b.Count && a.Value == b.Value);
 }