Exemple #1
0
        private bool FinnsDetEnLösning()
        {
            List <SudokuSökResultat> resultat = new List <SudokuSökResultat>();
            bool korrektPuzzel = true;

            do
            {
                resultat.Clear();
                foreach (Func <SudokuPussel, List <SudokuSökResultat>, bool> teknik in allaTekniker)
                {
                    if (teknik(this, resultat))
                    {
                        break;
                    }
                }
                this.PlaceraSiffra(resultat);
            }while (resultat.Count > 0);

            if (!SpelPlan.Any(ruta => ruta.Siffra == 0))
            {
                if (DubbletterIRad())
                {
                    korrektPuzzel = false;
                }
                if (DubletterIKolumn())
                {
                    korrektPuzzel = false;
                }
                if (DubbletterIBox())
                {
                    korrektPuzzel = false;
                }
            }
            else
            {
                korrektPuzzel = false;
            }
            return(korrektPuzzel);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            SpelPlan map1 = new SpelPlan();
            //Console.WriteLine(map1.spelplan);

            List <string> test = new List <string>();

            Dictionary <int, Dictionary <int, string> > testDic = new Dictionary <int, Dictionary <int, string> >();

            Dictionary <int, string> dic = new Dictionary <int, string>();

            Dictionary <int, string> dicO = new Dictionary <int, string>();

            Dictionary <List <int>, List <int> > cords = new Dictionary <List <int>, List <int> >();

            int skeppLängd = int.Parse(Console.ReadLine());

            List <int> nullCords = new List <int>();

            dicO = DefaultMap(dicO);
            xCordAll.Add(0, nullCords);
            yCordAll.Add(0, nullCords);


            testDic = DefaultMap1(testDic, dicO);

            for (int i = 0; i < 5; i++)
            {
                AddCords(skeppLängd, i + 1);

                ShipPutter(testDic, dicO, dic, i + 1);

                test2(testDic);
            }
            //TestTest(dic, testDic);

            Console.ReadKey();
        }