Exemple #1
0
        private int GetMinCount(string sodukuString, Dictionary <string, int> expressCount, List <int[]> switchList)
        {
            int min = 0;

            if (!expressCount.ContainsKey(sodukuString))
            {
                min = new DanceLink().solution_count(sodukuString);
                expressCount.Add(sodukuString, min);
            }
            else
            {
                min = expressCount[sodukuString];
            }

            int start = 0;
            int end   = 0;

            do
            {
                start = min;


                foreach (var switchListCouple in switchList)
                {
                    var newStr = StaticTools.SwitchLocation(sodukuString, switchListCouple[0], switchListCouple[1]);

                    if (!expressCount.ContainsKey(newStr))
                    {
                        var count = new DanceLink().solution_count(newStr);

                        //Console.WriteLine("newStr  " + newStr + "  " + count);
                        expressCount.Add(newStr, count);
                        if (count != 0 && count < min)
                        {
                            sodukuString = newStr;
                            min          = count;
                            break;
                        }
                    }
                }

                end = min;
            } while (start != end);

            return(min);
        }