SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var text = Console.ReadLine();
  14.            
  15.             List<string> words = text.
  16.                 Split('.', ',', ':', ';', '(', ')', '[',
  17.                 ']', '"', '\'', '\\', '/', '!', '?', ' ')
  18.                 .ToList();
  19.  
  20.             while (words.Count>0)
  21.             {
  22.                 var length = words.Sum(word => word.Length);
  23.  
  24.                 var minPower = words.Min(
  25.                     word => (double)word.Sum(letter => letter) / length
  26.                     );
  27.  
  28.                 var minWord = words.Single(word =>
  29.                     (double)word.Sum(letter => letter) / length == minPower
  30.                     );
  31.  
  32.                 Console.WriteLine(minWord);
  33.                 words.Remove(minWord);
  34.                 Console.WriteLine(String.Join(" ", words));
  35.             }
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top