Ejemplo n.º 1
0
        public string GetPairs()
        {
            //read last pairs here
            FileReadWrite file = new FileReadWrite();

            var yesterdayPairs = GetLastPairs(file.ReadFile()); //this returns a List<tuple> of canonical pairs
            var todayPairs     = new List <Tuple <string, string> >();

            var randomPair = _pairs.OrderBy(arg => Guid.NewGuid()).Take(2).ToList();

            todayPairs.Add(Tuple.Create(randomPair[0], randomPair[1]));

            while (yesterdayPairs.Contains(todayPairs[0]))
            {
                todayPairs = new List <Tuple <string, string> >();
                randomPair = _pairs.OrderBy(arg => Guid.NewGuid()).Take(2).ToList();

                todayPairs.Add(Tuple.Create(randomPair[0], randomPair[1]));
            }
            //then write the new pair
            file.WriteToFile($"{todayPairs[0].Item1.ToString()},{todayPairs[0].Item2.ToString()}");

            //return the new pair
            return($"Today's pairs are : {todayPairs[0].Item1.ToString()} & {todayPairs[0].Item2.ToString()}");
        }