Exemplo n.º 1
0
        public List <List <int> > SecondTriplet(List <List <int> > triplet, List <List <int> > ptriplet)
        {
            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3].Add(tablata[i % 3][i / 3]);
            }
            //  printaj();
            //  printajTriplet(triplet);
            triplet = shuffleTriplet(triplet, new List <int> {
                generator.Next(6), generator.Next(6), generator.Next(6)
            });
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {
                if (j == i)
                {
                    continue;
                }

                permutacii tri = new permutacii(new int[3] {
                    triplet[i][0], triplet[i][1], triplet[j][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                ptriplet[mesto].AddRange(tri.realni);
            }
            //  printajTriplet(vtriplet);

            return(ptriplet);
        }
Exemplo n.º 2
0
 public List <List <int> > shuffleTriplet(List <List <int> > triplet, List <int> ran)
 {
     for (int i = 0; i < 3; i++)
     {
         permutacii tri = new permutacii(triplet[i]);
         tri.OrderByNum(ran[i]);
         triplet[i] = tri.realni;
     }
     return(triplet);
 }
Exemplo n.º 3
0
        public List <List <int> > nshuffleTriplet(List <List <int> > triplet, List <int> ran)
        {
            List <List <int> > vrati = new List <List <int> >();

            for (int i = 0; i < 3; i++)
            {
                vrati.Add(new List <int>());
            }
            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(triplet[i]);
                tri.OrderByNum(ran[i]);
                vrati[i].AddRange(tri.realni);
            }
            return(vrati);
        }
Exemplo n.º 4
0
        public void FirstThree()
        {
            List <List <int> > triplet = new List <List <int> >();

            for (int i = 0; i < 3; i++)
            {
                triplet.Add(new List <int>());
            }
            int[]      niza    = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            permutacii pocetni = new permutacii(niza);

            pocetni.OrderByRan();
            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3].Add(pocetni.realni[i]);
            }
            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(triplet[i]);
                tri.OrderByRan();
                triplet[i] = tri.realni;
            }


            List <List <int> > vtriplet = new List <List <int> >();
            List <List <int> > ttriplet = new List <List <int> >();

            for (int i = 0; i < 3; i++)
            {
                ttriplet.Add(new List <int>());
                vtriplet.Add(new List <int>());
            }
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {
                if (j == i)
                {
                    continue;
                }

                permutacii tri = new permutacii(new int[3] {
                    triplet[i][0], triplet[i][1], triplet[j][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                vtriplet[mesto].AddRange(tri.realni);
                tri = new permutacii(new int[3] {
                    triplet[i][0], triplet[i][1], triplet[(j + 1) % 3][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                mesto = razlicnoOd(i, (j + 1) % 3);
                ttriplet[mesto].AddRange(tri.realni);
            }

            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(new int[3] {
                    triplet[i][0], triplet[i][1], triplet[i][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                triplet[i] = tri.realni;

                tri = new permutacii(new int[3] {
                    vtriplet[i][0], vtriplet[i][1], vtriplet[i][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                vtriplet[i] = tri.realni;

                tri = new permutacii(new int[3] {
                    ttriplet[i][0], ttriplet[i][1], ttriplet[i][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                ttriplet[i] = tri.realni;
            }

            int ebroj = 3, vbroj = 6;

            if (generator.Next(2) == 1)
            {
                int temp = ebroj; ebroj = vbroj; vbroj = temp;
            }
            for (int i = 0; i < 9; i++)
            {
                tablata[i / 3][i % 3]           = triplet[i / 3][i % 3];
                tablata[i / 3][ebroj + (i % 3)] = vtriplet[i / 3][i % 3];
                tablata[i / 3][vbroj + (i % 3)] = ttriplet[i / 3][i % 3];
            }

            //   printaj();

            //     printajTripleti(triplet, vtriplet, ttriplet);
        }
Exemplo n.º 5
0
        public bool SecondThree(List <int> nizaZaParovi, int doKade, int Kade,
                                List <int> nizaZaPrviot, bool second)
        {
            List <List <int> > triplet  = new List <List <int> >();
            List <List <int> > vtriplet = new List <List <int> >();
            List <List <int> > ttriplet = new List <List <int> >();
            List <List <int> > ptriplet = new List <List <int> >();

            for (int i = 0; i < 3; i++)
            {
                triplet.Add(new List <int>());
                vtriplet.Add(new List <int>());
                ttriplet.Add(new List <int>());
                ptriplet.Add(new List <int>());
            }
            if (second)
            {
                ptriplet = SecondTriplet(triplet, ptriplet);
            }

            ptriplet = shuffleTriplet(ptriplet, nizaZaPrviot);  // ova se mesti samoto sebe
            ptriplet = transpose(ptriplet);


            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3][i % 3] = ptriplet[i / 3][i % 3];
            }
            ptriplet = shuffleTriplet(ptriplet, nizaZaParovi);   // ova mesti parovi i singles
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {
                if (j == i)
                {
                    continue;
                }

                permutacii tri = new permutacii(new int[3] {
                    ptriplet[i][0], ptriplet[i][1], ptriplet[j][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                vtriplet[mesto].AddRange(tri.realni);
                tri = new permutacii(new int[3] {
                    ptriplet[i][0], ptriplet[i][1], ptriplet[(j + 1) % 3][2]
                });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                mesto = razlicnoOd(i, (j + 1) % 3);
                ttriplet[mesto].AddRange(tri.realni);
            }
            if (!second)
            {
                printaj();
                //      printajTripleti(ptriplet, vtriplet, ttriplet);
                Console.WriteLine(!check(doKade, 3, vtriplet) || !check(doKade, 6, ttriplet));
                Console.ReadKey();
            }
            if (!check(doKade, 3, vtriplet) || !check(doKade, 6, ttriplet))
            {
                return(false);
            }
            for (int i = 0; i < 9; i++)
            {
                ptriplet[i / 3][i % 3] = vtriplet[i / 3][i % 3];
            }
            for (int i = generator.Next(216), j = 0; j < 216; j++, i = (i + 7) % 216)
            {
                // Console.WriteLine("ima volku poedineecno " + j+ff);
                if (j == 210)
                {
                    Console.WriteLine("ima volku poedineecno " + j);
                }
                vtriplet = nshuffleTriplet(ptriplet, Perm(i));


                if (checkPoedinecno(doKade, 3, vtriplet))
                {
                    // Console.WriteLine("ima volku poedineecno " + j);
                    break;
                }
            }


            for (int i = 0; i < 9; i++)
            {
                ptriplet[i / 3][i % 3] = ttriplet[i / 3][i % 3];
            }

            for (int i = generator.Next(216), j = 0; j < 216; j++, i = (i + 7) % 216)
            {
                // Console.WriteLine("ima volku poedineecno " + j+ff);

                ttriplet = nshuffleTriplet(ptriplet, Perm(i));
                if (j == 210)
                {
                    Console.WriteLine("ima volku poedineecno " + j);
                }

                if (checkPoedinecno(doKade, 6, ttriplet))
                {
                    //Console.WriteLine("ima volku poedineecno " + j );
                    break;
                }
            }
            for (int i = 0; i < 9; i++)
            {
                tablata[Kade + i / 3][i % 3]       = triplet[i / 3][i % 3];
                tablata[Kade + i / 3][3 + (i % 3)] = vtriplet[i / 3][i % 3];
                tablata[Kade + i / 3][6 + (i % 3)] = ttriplet[i / 3][i % 3];
            }

            //               printaj();
            return(true);


            //  printajTriplet(triplet);
        }
Exemplo n.º 6
0
        public List<List<int>> shuffleTriplet(List<List<int>> triplet, List<int> ran)
        {
            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(triplet[i]);
                tri.OrderByNum(ran[i]);
                triplet[i] = tri.realni;

            }
            return triplet;
        }
Exemplo n.º 7
0
        public List<List<int>> SecondTriplet(List<List<int>> triplet, List<List<int>> ptriplet)
        {
            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3].Add(tablata[i % 3][i / 3]);

            }
            //  printaj();
            //  printajTriplet(triplet);
            triplet = shuffleTriplet(triplet, new List<int> { generator.Next(6), generator.Next(6), generator.Next(6) });
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {

                if (j == i) continue;

                permutacii tri = new permutacii(new int[3] { triplet[i][0], triplet[i][1], triplet[j][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                ptriplet[mesto].AddRange(tri.realni);

            }
            //  printajTriplet(vtriplet);

            return ptriplet;
        }
Exemplo n.º 8
0
        public bool SecondThree(List<int> nizaZaParovi, int doKade, int Kade,
            List<int> nizaZaPrviot, bool second)
        {
            List<List<int>> triplet = new List<List<int>>();
            List<List<int>> vtriplet = new List<List<int>>();
            List<List<int>> ttriplet = new List<List<int>>();
            List<List<int>> ptriplet = new List<List<int>>();
            for (int i = 0; i < 3; i++)
            {
                triplet.Add(new List<int>());
                vtriplet.Add(new List<int>());
                ttriplet.Add(new List<int>());
                ptriplet.Add(new List<int>());
            }
            if (second)
                ptriplet = SecondTriplet(triplet, ptriplet);

            ptriplet = shuffleTriplet(ptriplet, nizaZaPrviot);  // ova se mesti samoto sebe
            ptriplet = transpose(ptriplet);

            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3][i % 3] = ptriplet[i / 3][i % 3];

            }
            ptriplet = shuffleTriplet(ptriplet, nizaZaParovi);   // ova mesti parovi i singles
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {

                if (j == i) continue;

                permutacii tri = new permutacii(new int[3] { ptriplet[i][0], ptriplet[i][1], ptriplet[j][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                vtriplet[mesto].AddRange(tri.realni);
                tri = new permutacii(new int[3] { ptriplet[i][0], ptriplet[i][1], ptriplet[(j + 1) % 3][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                mesto = razlicnoOd(i, (j + 1) % 3);
                ttriplet[mesto].AddRange(tri.realni);

            }
            if (!second)
            {
                printaj();
                //      printajTripleti(ptriplet, vtriplet, ttriplet);
                Console.WriteLine(!check(doKade, 3, vtriplet) || !check(doKade, 6, ttriplet));
                Console.ReadKey();
            }
            if (!check(doKade, 3, vtriplet) || !check(doKade, 6, ttriplet)) return false;
            for (int i = 0; i < 9; i++)
            {
                ptriplet[i / 3][i % 3] = vtriplet[i / 3][i % 3];

            }
            for (int i = generator.Next(216), j = 0; j < 216; j++, i = (i + 7) % 216)
            {

                // Console.WriteLine("ima volku poedineecno " + j+ff);
                if (j == 210) Console.WriteLine("ima volku poedineecno " + j);
                vtriplet = nshuffleTriplet(ptriplet, Perm(i));

                if (checkPoedinecno(doKade, 3, vtriplet))
                {
                    // Console.WriteLine("ima volku poedineecno " + j);
                    break;
                }

            }

            for (int i = 0; i < 9; i++)
            {
                ptriplet[i / 3][i % 3] = ttriplet[i / 3][i % 3];

            }

            for (int i = generator.Next(216), j = 0; j < 216; j++, i = (i + 7) % 216)
            {

                // Console.WriteLine("ima volku poedineecno " + j+ff);

                ttriplet = nshuffleTriplet(ptriplet, Perm(i));
                if (j == 210) Console.WriteLine("ima volku poedineecno " + j);

                if (checkPoedinecno(doKade, 6, ttriplet))
                {
                    //Console.WriteLine("ima volku poedineecno " + j );
                    break;
                }

            }
            for (int i = 0; i < 9; i++)
            {
                tablata[Kade + i / 3][i % 3] = triplet[i / 3][i % 3];
                tablata[Kade + i / 3][3 + (i % 3)] = vtriplet[i / 3][i % 3];
                tablata[Kade + i / 3][6 + (i % 3)] = ttriplet[i / 3][i % 3];
            }

            //               printaj();
            return true;

            //  printajTriplet(triplet);
        }
Exemplo n.º 9
0
        public List<List<int>> nshuffleTriplet(List<List<int>> triplet, List<int> ran)
        {
            List<List<int>> vrati = new List<List<int>>();

            for (int i = 0; i < 3; i++)
                vrati.Add(new List<int>());
            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(triplet[i]);
                tri.OrderByNum(ran[i]);
                vrati[i].AddRange(tri.realni);

            }
            return vrati;
        }
Exemplo n.º 10
0
        public void FirstThree()
        {
            List<List<int>> triplet = new List<List<int>>();
            for (int i = 0; i < 3; i++)
            {
                triplet.Add(new List<int>());

            }
            int[] niza = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            permutacii pocetni = new permutacii(niza);

            pocetni.OrderByRan();
            for (int i = 0; i < 9; i++)
            {
                triplet[i / 3].Add(pocetni.realni[i]);

            }
            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(triplet[i]);
                tri.OrderByRan();
                triplet[i] = tri.realni;

            }

            List<List<int>> vtriplet = new List<List<int>>();
            List<List<int>> ttriplet = new List<List<int>>();
            for (int i = 0; i < 3; i++)
            {
                ttriplet.Add(new List<int>());
                vtriplet.Add(new List<int>());
            }
            for (int i = 0, j = 1; i < 3; i++, j = (j + 1) % 3)
            {

                if (j == i) continue;

                permutacii tri = new permutacii(new int[3] { triplet[i][0], triplet[i][1], triplet[j][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                int mesto = razlicnoOd(i, j);
                vtriplet[mesto].AddRange(tri.realni);
                tri = new permutacii(new int[3] { triplet[i][0], triplet[i][1], triplet[(j + 1) % 3][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                mesto = razlicnoOd(i, (j + 1) % 3);
                ttriplet[mesto].AddRange(tri.realni);

            }

            for (int i = 0; i < 3; i++)
            {
                permutacii tri = new permutacii(new int[3] { triplet[i][0], triplet[i][1], triplet[i][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                triplet[i] = tri.realni;

                tri = new permutacii(new int[3] { vtriplet[i][0], vtriplet[i][1], vtriplet[i][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                vtriplet[i] = tri.realni;

                tri = new permutacii(new int[3] { ttriplet[i][0], ttriplet[i][1], ttriplet[i][2] });
                tri.OrderByNum(generator.Next(permutacii.Faktoriel(3)));
                ttriplet[i] = tri.realni;

            }

            int ebroj = 3, vbroj = 6;
            if (generator.Next(2) == 1)
            {
                int temp = ebroj; ebroj = vbroj; vbroj = temp;
            }
            for (int i = 0; i < 9; i++)
            {
                tablata[i / 3][i % 3] = triplet[i / 3][i % 3];
                tablata[i / 3][ebroj + (i % 3)] = vtriplet[i / 3][i % 3];
                tablata[i / 3][vbroj + (i % 3)] = ttriplet[i / 3][i % 3];
            }

            //   printaj();

            //     printajTripleti(triplet, vtriplet, ttriplet);
        }