Пример #1
0
 public bool IsLessThan(Pokéset other)
 {
     if (Length() < other.Length())
     {
         return(true);
     }
     if (Length() == other.Length())
     {
         return(TotalLength() < other.TotalLength());
     }
     return(false);
 }
Пример #2
0
 static void AddNextToSet(Pokéset set)
 {
     foreach (var pokémon in pokédex.Map()[pokédex.CharsInOrder().Except(set.Chars()).First()])
     {
         var newSet = new Pokéset(set.Set().Concat(new[] { pokémon }).ToArray());
         if (newSet.Code() == ALPHABET)
         {
             if (newSet.IsLessThanOrEqualTo(minPokéset))
             {
                 minPokéset = newSet;
                 Console.WriteLine("After {0} seconds, found new min_set: {1}", (DateTime.Now - time).TotalSeconds, minPokéset);
             }
         }
         else if (CanAddTwoMore(newSet) || CanAddOneMore(newSet))
         {
             AddNextToSet(newSet);
         }
     }
 }
Пример #3
0
        static void Main(string[] args)
        {
            time = DateTime.Now;

            pokédex = new Pokédex(args.Any() ? args[0] : @"..\..\pokemon.txt");

            minPokéset = new Pokéset(pokédex.All().ToArray());

            Parallel.ForEach(pokédex.Map()[pokédex.CharsInOrder()[0]], pokémon =>
            {
                var set = new Pokéset(new[] { pokémon });
                if (set.Code() < ALPHABET)
                {
                    AddNextToSet(set);
                }
            });

            Console.WriteLine("Found min_set: {0}. Completed in {1} seconds", minPokéset, (DateTime.Now - time).TotalSeconds);
        }
Пример #4
0
 private static bool CanAddOneMore(Pokéset newSet)
 {
     return(newSet.Length() + 1 == minPokéset.Length() && newSet.TotalLength() + newSet.MissingCharCount() <= minPokéset.TotalLength());
 }
Пример #5
0
 static bool CanAddTwoMore(Pokéset set)
 {
     return(set.Length() + 1 < minPokéset.Length());
 }