Example #1
0
 public void gime()
 {
     if (tesSol) return;
     string[] cores = new string[] { "ivory", "Red", "Green" };
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(3); ++k)
     {
         StringPerm p = new StringPerm(cores, k);
         color1 = p.element[0].ToString();
         color2  = p.element[1].ToString();
         color3 = p.element[2].ToString();
         gimeAnimais( new string[] {"snails", "Dog", "fox", "Zebra"});
     }
 }
Example #2
0
        /// <summary>
        /// Gimes the countries.
        /// </summary>
        public void gimecountrys(string[] countrys)
        {
            if (tesSol)
            {
                return;
            }
            for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
            {
                StringPerm p = new StringPerm(countrys, k);
                country1 = p.element[0].ToString();
                country2 = p.element[1].ToString();
                country3 = p.element[2].ToString();
                country4 = p.element[3].ToString();



                Guy[] vizinhosArray = new Guy[5] {
                    new Guy("yellow", animal1, "Kools", 1, drink1, "Norwegian"),
                    new Guy("blue", "horse", smoke11, 2, drink2, country1),
                    new Guy(color1, animal2, smoke12, 3, "Milk", country2),
                    new Guy(color2, animal3, smoke13, 4, drink3, country3),
                    new Guy(color3, animal4, smoke14, 5, drink4, country4),
                };
                Vizinhos vizinhoslist = new Vizinhos(vizinhosArray);
                bool     val          = vizinhoslist.Valida();
                if (val == true)
                {
                    tesSol      = true;
                    Solucao[0]  = color1;
                    Solucao[1]  = color2;
                    Solucao[2]  = color3;
                    Solucao[3]  = animal1;
                    Solucao[4]  = animal2;
                    Solucao[5]  = animal3;
                    Solucao[6]  = animal4;
                    Solucao[7]  = smoke11;
                    Solucao[8]  = smoke12;
                    Solucao[9]  = smoke13;
                    Solucao[10] = smoke14;
                    Solucao[11] = drink1;
                    Solucao[12] = drink2;
                    Solucao[13] = drink3;
                    Solucao[14] = drink4;
                    Solucao[15] = country1;
                    Solucao[16] = country2;
                    Solucao[17] = country3;
                    Solucao[18] = country4;
                }
            }
        }
Example #3
0
 /// <summary>
 /// Gime the drinks.
 /// </summary>
 public void gimedrinks(string[] drinks)
 {
     if (tesSol)
     {
         return;
     }
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(drinks, k);
         drink1 = p.element[0].ToString();
         drink2 = p.element[1].ToString();
         drink3 = p.element[2].ToString();
         drink4 = p.element[3].ToString();
         gimecountrys(new string[] { "Spaniard", "Ukrainian", "Englishman", "Japanese" });
     }
 }
Example #4
0
 /// <summary>
 /// Gime the smoke1.
 /// </summary>
 public void gimesmoke1(string[] smoke1s)
 {
     if (tesSol)
     {
         return;
     }
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(smoke1s, k);
         smoke11 = p.element[0].ToString();
         smoke12 = p.element[1].ToString();
         smoke13 = p.element[2].ToString();
         smoke14 = p.element[3].ToString();
         gimedrinks(new string[] { "Coffee", "Tea", "orange juice", "Water" });
     }
 }
Example #5
0
 /// <summary>
 /// Gime the animals.
 /// </summary>
 public void gimeAnimais(string[] atoms)
 {
     if (tesSol)
     {
         return;
     }
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(atoms, k);
         animal1 = p.element[0].ToString();
         animal2 = p.element[1].ToString();
         animal3 = p.element[2].ToString();
         animal4 = p.element[3].ToString();
         gimesmoke1(new string[] { "Parliaments", "Lucky Strike", "Chesterfield", "Old Gold" });
     }
 }
Example #6
0
 public void gime()
 {
     if (tesSol)
     {
         return;
     }
     string[] cores = new string[] { "ivory", "Red", "Green" };
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(3); ++k)
     {
         StringPerm p = new StringPerm(cores, k);
         color1 = p.element[0].ToString();
         color2 = p.element[1].ToString();
         color3 = p.element[2].ToString();
         gimeAnimais(new string[] { "snails", "Dog", "fox", "Zebra" });
     }
 }
Example #7
0
        public StringPerm Successor() // assumes no duplicate atoms
        {
            StringPerm result = new StringPerm(this.element);
            int        left, right;

            left = result.order - 2;  // Step #1 - Find left value
            while ((result.element[left].CompareTo(result.element[left + 1])) > 0 && (left >= 1))
            {
                --left;
            }
            if ((left == 0) && (this.element[left].CompareTo(this.element[left + 1])) > 0)
            {
                return(null);
            }

            right = result.order - 1;  // Step #2 - find right; first value > left
            while (result.element[left].CompareTo(result.element[right]) > 0)
            {
                --right;
            }

            string temp = result.element[left];  // Step #3 - swap [left] and [right]

            result.element[left]  = result.element[right];
            result.element[right] = temp;

            int i = left + 1;              // Step #4 - reverse order the tail
            int j = result.order - 1;

            while (i < j)
            {
                temp = result.element[i];
                result.element[i++] = result.element[j];
                result.element[j--] = temp;
            }

            //return result;
            return(result);
        } // Successor()
Example #8
0
 /// <summary>
 /// Gime the animals.
 /// </summary>
 public void gimeAnimais(string[] atoms)
 {
     if (tesSol) return;
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(atoms, k);
         animal1 = p.element[0].ToString();
         animal2 =  p.element[1].ToString();
         animal3=  p.element[2].ToString();
         animal4=  p.element[3].ToString();
         gimesmoke1(new string[] {"Parliaments", "Lucky Strike", "Chesterfield", "Old Gold"});
     }
 }
Example #9
0
 /// <summary>
 /// Gime the smoke1.
 /// </summary>
 public void gimesmoke1(string[] smoke1s)
 {
     if (tesSol) return;
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(smoke1s, k);
         smoke11 = p.element[0].ToString();
         smoke12 =  p.element[1].ToString();
         smoke13 =  p.element[2].ToString();
         smoke14 =  p.element[3].ToString();
         gimedrinks(new string[] {"Coffee", "Tea", "orange juice", "Water"});
     }
 }
Example #10
0
 /// <summary>
 /// Gime the drinks.
 /// </summary>
 public void gimedrinks(string[] drinks)
 {
     if (tesSol) return;
     for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k)
     {
         StringPerm p = new StringPerm(drinks, k);
         drink1= p.element[0].ToString();
         drink2=  p.element[1].ToString();
         drink3=  p.element[2].ToString();
         drink4=  p.element[3].ToString();
         gimecountrys(new string[] {"Spaniard", "Ukrainian", "Englishman", "Japanese"});
     }
 }
Example #11
0
        /// <summary>
        /// Gimes the countries.
        /// </summary>
        public void gimecountrys(string[] countrys)
        {
            if (tesSol) return;
            for (int k = 0; (ulong)k < StringPerm.FactorialLookup(4); ++k) {
                StringPerm p = new StringPerm (countrys, k);
                country1 = p.element [0].ToString ();
                country2 = p.element [1].ToString ();
                country3 = p.element [2].ToString ();
                country4 = p.element [3].ToString ();

                Guy[] vizinhosArray = new Guy[5] {
                    new Guy ("yellow", animal1, "Kools", 1, drink1, "Norwegian"),
                    new Guy ("blue", "horse", smoke11, 2, drink2, country1),
                    new Guy (color1, animal2, smoke12, 3, "Milk", country2),
                    new Guy (color2, animal3, smoke13, 4, drink3, country3),
                    new Guy (color3, animal4, smoke14, 5, drink4, country4),

                };
                Vizinhos vizinhoslist= new Vizinhos(vizinhosArray);
                bool val = vizinhoslist.Valida();
                if (val==true)
                {
                    tesSol = true;
                    Solucao[0] =color1;
                    Solucao[1] =color2;
                    Solucao[2] =color3;
                    Solucao[3] =animal1;
                    Solucao[4] =animal2;
                    Solucao[5] =animal3;
                    Solucao[6] =animal4;
                    Solucao[7] =smoke11;
                    Solucao[8] =smoke12;
                    Solucao[9] =smoke13;
                    Solucao[10] =smoke14;
                    Solucao[11] =drink1;
                    Solucao[12] =drink2;
                    Solucao[13] =drink3;
                    Solucao[14] =drink4;
                    Solucao[15] =country1;
                    Solucao[16] =country2;
                    Solucao[17] =country3;
                    Solucao[18] =country4;

                }

            }
        }
Example #12
0
        // assumes no duplicate atoms
        public StringPerm Successor()
        {
            StringPerm result = new StringPerm(this.element);
            int left, right;

            left = result.order - 2;  // Step #1 - Find left value
            while ((result.element[left].CompareTo(result.element[left + 1])) > 0 && (left >= 1))
            {
                --left;
            }
            if ((left == 0) && (this.element[left].CompareTo(this.element[left + 1])) > 0)
                return null;

            right = result.order - 1;  // Step #2 - find right; first value > left
            while (result.element[left].CompareTo(result.element[right]) > 0)
            {
                --right;
            }

            string temp = result.element[left];  // Step #3 - swap [left] and [right]
            result.element[left] = result.element[right];
            result.element[right] = temp;

            int i = left + 1;              // Step #4 - reverse order the tail
            int j = result.order - 1;

            while (i < j)
            {
                temp = result.element[i];
                result.element[i++] = result.element[j];
                result.element[j--] = temp;
            }

            //return result;
            return result;
        }