Exemplo n.º 1
0
        /// <summary>
        /// 简单随机搜索
        /// </summary>
        /// <param name="sodukuString"></param>
        /// <returns></returns>
        private string EasySearch(string sodukuString)
        {
            var matrix         = StaticTools.StringToList(sodukuString);
            var locations      = StaticTools.GetLocations(matrix);
            var otherLocations = StaticTools.allLocations.Except(locations).ToList();
            Dictionary <string, int> sodukumap = new Dictionary <string, int>();

            foreach (var loc in locations)
            {
                var newstr      = StaticTools.SetZero(sodukuString, loc);
                var answerCount = new DanceLink().solution_count(newstr);
                sodukumap.Add(newstr, answerCount);
            }

            var tempResult = "";
            var index      = 1;

            foreach (var newGene in sodukumap)
            {
                //Console.WriteLine("存在多解的提示数  \r\n" + newGene);
                //Console.WriteLine("进展:   " +"处理了"+ index+"条,总数是  "+ sodukumap.Count);
                index     += 1;
                tempResult = newClues(newGene.Key, otherLocations);
            }


            Console.WriteLine("最终提示数表达式为\r\n" + tempResult);


            return(tempResult);
        }
Exemplo n.º 2
0
        private static List <int> ExceptOtherPearlGene(IEnumerable <int> otherLocations, List <int> locations,
                                                       string oneAnswer)
        {
            var exceptList = new List <int>();

            foreach (var loc in otherLocations)
            {
                var newlocations = StaticTools.allLocations.Except(locations.Union(new List <int> {
                    loc
                }));
                var newGens = StaticTools.SetZero(oneAnswer, newlocations);
                if (StaticTools.IsPearl(newGens))
                {
                    exceptList.Add(loc);
                }
            }

            return(exceptList);
        }
Exemplo n.º 3
0
        private string GetPureGene(string oneAnswer, string clues, IEnumerable <int> pure)
        {
            var choose = 2;


            var ints = PermutationAndCombination <int> .GetCombination(pure.ToArray(), choose);

            //Console.WriteLine("组合元素个数   " + pure.Count());
            //Console.WriteLine("choose   " + choose);
            //Console.WriteLine("组合个数   " + ints.Count);
            var locations = StaticTools.GetLocations(clues);

            int computedCount = 0;
            int index         = 0;

            foreach (var t in ints)
            {
                var newClues = StaticTools.SetZero(oneAnswer,
                                                   StaticTools.allLocations.Except(t.Union(locations)));
                computedCount += 1;
                if (computedCount == 10000)
                {
                    index        += 1;
                    computedCount = 0;
                    Console.WriteLine("已处理   " + index + "万条数据" + DateTime.Now);
                }

                if (StaticTools.IsPearl(newClues))
                {
                    var result = newClues;

                    return(result);
                }
            }
            return("");
        }