示例#1
0
        public Puzzle4()
        {
            allWords = DictReader.ReadDict("Dutch").Where(t => t.Length > 2).ToList();
            allWords.AddRange(allWords.ToList().Select(t => t + "e"));

            Console.WriteLine("Filtering words");
            allWords = allWords.Where(t => t.All(z => CharValueHelper.CharArray.Contains(z))).ToList();
            Console.WriteLine("Done");
        }
示例#2
0
    void Awake()
    {
        //Make sure this is in fact the only instance (Singleton pattern)
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);

        DictReader dictReader = new DictReader(resourceLocation);

        m_data = new Dictionary <int, BuildingInfo> ();

        foreach (var row in dictReader)
        {
            //	Debug.Log (row ["ID"] + ", " +
            //	row ["IMAGE"] + ", " +
            //	row ["ARCHITECT"] + ", " +
            //	row ["BUILDING"] + ", " +
            //	row ["HEX"] + ", " +
            //	row ["RGB"] + ", " +
            //	row ["QUOTE"] + ", " +
            //	row ["BLOCK"]
            //	);

            BuildingInfo info = new BuildingInfo();
            info.m_image        = row ["IMAGE"];
            info.m_architect    = row ["ARCHITECT"];
            info.m_buildingName = row ["BUILDING"];
            Color c = new Color();
            ColorUtility.TryParseHtmlString("#" + row ["HEX"], out c);
            info.m_color = c;
            //Debug.Log (c.ToString ());
            info.m_quote  = row ["QUOTE"];
            info.m_block  = row ["BLOCK"];
            info.m_sprite = Resources.Load <Sprite> ("BuildingSprites/" + info.m_image);

            m_data.Add(Convert.ToInt32(row ["ID"]), info);
        }


        //Debug.Log (dictReader);
    }
示例#3
0
        public void GetTest()
        {
            var list = new List<TestClass>
            {
                new TestClass() { Id = 1, Name = "小明" },
                new TestClass() { Id = 2, Name = "小王" },
                new TestClass() { Id = 3, Name = "小陈" },
            };

            var reader = new DictReader<int, TestClass>(
                list,
                it => it.Id,
                new TestClass
                {
                    Id = 0,
                    Name = "未知"
                });

            Assert.AreEqual("小王", reader.Get(2).Name);
            Assert.AreEqual("未知", reader.Get(99).Name);
        }
示例#4
0
        public void Go()
        {
            var grid = new Gridje <int>(5, 8);



            var data = new List <List <string> >
            {
                new List <string>()
                {
                    "aachi"
                },
                new List <string>()
                {
                    "alntt", "bdttu"
                },
                new List <string>()
                {
                    "aelrw", "afitw"
                },
                new List <string>()
                {
                    "aemov", "afkmy"
                },
                new List <string>()
                {
                    "ansuv"
                },
                new List <string>()
                {
                    "anrst", "aopsu"
                },
                new List <string>()
                {
                    "cceen"
                },
                new List <string>()
                {
                    "airst"
                },
            };

            var combinations = data.Aggregate(1, (x, y) => x * y.Count);

            var numberListBase = new List <int>()
            {
                0, 0, 0,
                1,
                2, 2,
                1, 1,
                2, 3, 4, 5,
                5, 5,
                6, 6, 6,
                7, 7, 7, 7, 7,
                6, 6,
                5, 4,
                4, 4,
                3, 3, 3,
                2, 1, 0,
                0, 1, 2, 3, 4, 5
            };

            //var numberListBase = new List<int>()
            //{
            //    0, 0, 0,
            //    1,
            //    2, 2,
            //    1, 1,
            //    2, 3, 3, 4, 4, 5,
            //    5, 5,
            //    6, 6, 6,
            //    7, 7, 7, 7, 7,
            //    6, 6,
            //    5, 4,
            //    4,
            //    3, 3,
            //    2, 1, 0,
            //    0, 1, 2, 3, 4, 5
            //};

            //numberListBase.Reverse();

            var allWorlds = DictReader.ReadDict("Dutch").Concat(DictReader.ReadDict("Voornamen")).ToArray();
            //allWorlds = allWorlds.Select(t => t.ReverseString()).ToArray();
            //var blah = allWorlds.Where(t => t.Contains("a") && t.Contains("i") && t.Contains("r") && t.Contains("s") && t.Contains("t")).ToList();

            var corrects = new List <string>()
            {
                "acht",
                //"van",
                //"scenarist",
                //"massa",
                //"",
                //"wens",
                //"opeens",
            };

            var filtered = new HashSet <string>();

            for (int i = 0; i < combinations; i++)
            {
                Console.WriteLine($"Attempt: {i}");

                var part1 = GetLijst(data, i);
                var part2 = ToCharList(part1);
                var numberListToWorkWith = numberListBase.ToList();

                for (int zz = 0; zz < corrects.Count + 1; zz++)
                {
                    bool foundhere = false;

                    for (int y = 0; y < allWorlds.Length; y++)
                    {
                        var theDataToWorkWith = Clone(part2);
                        var curWord           = allWorlds[y];



                        bool completed = true;
                        for (int z = 0; z < curWord.Length; z++)
                        {
                            var nr      = numberListToWorkWith[z];
                            var curChar = curWord[z];
                            if (theDataToWorkWith[nr].Contains(curChar))
                            {
                                theDataToWorkWith[nr].Remove(curChar);
                            }
                            else
                            {
                                completed = false;
                                break;
                            }
                        }

                        if (completed)
                        {
                            if (zz >= corrects.Count)
                            {
                                Console.WriteLine($"Cycle: {zz}, Potential: {curWord}");
                                filtered.Add(curWord);
                            }

                            if (zz < corrects.Count)
                            {
                                if (curWord == corrects[zz])
                                {
                                    part2 = theDataToWorkWith;
                                    numberListToWorkWith = numberListToWorkWith.Skip(curWord.Length).ToList();
                                    foundhere            = true;

                                    //if (zz == 0)
                                    //{
                                    //    AddToChars(part2, 8);
                                    //}
                                }
                            }
                        }
                    }

                    if (!foundhere)
                    {
                        break;
                    }
                    Console.WriteLine();
                }



                //LogList(part2);



                Console.WriteLine();
            }

            Console.WriteLine("Filtered:");
            foreach (var word in filtered.OrderBy(t => t.Length).ThenBy(t => t))
            {
                //word = word.ReverseString();
                Console.WriteLine(word);
            }
        }