Advertisement
bullit3189

Short Words Sorted - Arrays and LINQ

Jan 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7. public static void Main()
  8. {
  9. string input = Console.ReadLine().ToLower();
  10.  
  11. char[] delimeters = new char[] {' ','.',',',':',';','(',')','[',']','"','\'','\\','/','!','?'};
  12. string[] tokens = input.Split(delimeters, StringSplitOptions.RemoveEmptyEntries).Where(w=>w.Length<5).Distinct().OrderBy(w=>w).ToArray();
  13.  
  14. Console.WriteLine(string.Join(", ",tokens));
  15.  
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement