Esempio n. 1
0
        private bool IsValid(string ten, TimTenOption option)
        {
            if (option.KyList.Contains(ten))
            {
                return(false);
            }

            if (option.DungKhongDau || option.DungDauHuyen || option.DungDauSac ||
                option.DungDauHoi || option.DungDauNga || option.DungDauNang)
            {
                if ((option.DungKhongDau && IsChuKhongDau(ten)) ||
                    (option.DungDauHuyen && IsChuCoDauHuyen(ten)) ||
                    (option.DungDauSac && IsChuCoDauSac(ten)) ||
                    (option.DungDauHoi && IsChuCoDauHoi(ten)) ||
                    (option.DungDauNga && IsChuCoDauNga(ten)) ||
                    (option.DungDauNang && IsChuCoDauNang(ten)))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public string Get2ChuCoTong(int tongSo, TimTenOption lotOption, TimTenOption tenOption)
        {
            var list = new List <string>();

            for (int i = 0; i < tongSo; i++)
            {
                if (i >= lotOption.MinNameLength && i <= lotOption.MaxNameLength)
                {
                    int lenChuLot = i;
                    int lenTen    = tongSo - i;

                    if (lenTen >= tenOption.MinNameLength)
                    {
                        list.AddRange(GetTenNu(tongSo, lenChuLot, lenTen, lotOption, tenOption));
                    }
                }
            }

            var sortedNameList = list.OrderBy(name => name).ToList();
            var result         = GetNamesInString(sortedNameList);

            return(result);
        }
Esempio n. 3
0
        private List <string> GetTenVaLot(int tongSo, List <string> listTen1, List <string> listTen2, TimTenOption lotOption, TimTenOption tenOption)
        {
            var list = new List <string>();

            foreach (var chuLot in listTen1)
            {
                // Ignore these name.
                if (!IsValid(chuLot, lotOption))
                {
                    continue;
                }

                foreach (var ten in listTen2)
                {
                    // Ignore these name.
                    if (!IsValid(ten, tenOption))
                    {
                        continue;
                    }

                    if (chuLot.Length + ten.Length != tongSo)
                    {
                        continue;
                    }

                    list.Add($"{chuLot} {ten}");
                }
            }

            return(list);
        }
Esempio n. 4
0
        public List <string> GetListTen(List <string> listAllTen, int tongSo, int tenLength1, int tenLength2, TimTenOption lotOption, TimTenOption tenOption)
        {
            var list = new List <string>();

            var listChuLot = lotOption.ChonList.Count > 0 ? lotOption.ChonList : GetAllNamesByLength(listAllTen, tenLength1);
            var listTen    = tenOption.ChonList.Count > 0 ? tenOption.ChonList : (tenLength1 != tenLength2 ? GetAllNamesByLength(listAllTen, tenLength2) : listChuLot);

            list.AddRange(GetTenVaLot(tongSo, listChuLot, listTen, lotOption, tenOption));

            return(list);
        }
Esempio n. 5
0
 private List <string> GetTenNu(int tongSo, int tenLength1, int tenLength2, TimTenOption lotOption, TimTenOption tenOption)
 {
     return(GetListTen(_tatCaTenNuVaLot, tongSo, tenLength1, tenLength2, lotOption, tenOption));
 }