Advertisement
Layvu

LQ3

Mar 20th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Drawing;
  5. using System.Text;
  6.  
  7. namespace ClassWork
  8. {
  9.     internal class Program
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             foreach (var line in ThirdTask(new[] {"abc", "bgf", "aab", "Ffg", "fdgOkM"}))
  14.             {
  15.                 Console.WriteLine(line);
  16.             }
  17.         }
  18.  
  19.         public static string[] ThirdTask(string[] lines)
  20.         {
  21.             var letterCounter = lines
  22.                 .Select(line => line.ToLower().ToCharArray()
  23.                     .GroupBy(symb => symb)
  24.                     .Select(group => Tuple.Create(group.Key, group.Count())))
  25.                 .Where(dict => dict.All(x => x.Item2 == 1));
  26.            
  27.             return letterCounter
  28.                 .Select(tuple =>
  29.                 {
  30.                     var str = new StringBuilder();
  31.                     foreach (var x in tuple) str.Append(x.Item1);
  32.                     return str.ToString();
  33.                 })
  34.                 .ToArray();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement