Пример #1
0
        //question2
        public string GetCommonString()
        {
            string[] ids = System.IO.File.ReadAllLines(inputPath);
            var      res = new RepeatCounter();

            for (int i = 0; i < ids.Length; i++)
            {
                for (int j = i + 1; j < ids.Length; j++)
                {
                    string id1 = ids[i];
                    string id2 = ids[j];
                    if (Distance(id1, id2) == 1)
                    {
                        return(CommonString(id1, id2));
                    }
                }
            }
            return(null);
        }
Пример #2
0
        private RepeatCounter Count(string s)
        {
            int[] counter = new int[26];
            var   res     = new RepeatCounter();

            foreach (char c in s.ToCharArray())
            {
                counter[(c - 'a')]++;
            }
            foreach (int count in counter)
            {
                if (count == 2)
                {
                    res.DoubleCount = 1;
                }
                else if (count == 3)
                {
                    res.TripleCount = 1;
                }
            }
            return(res);
        }