Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var text = Console.ReadLine();
- List<string> words = text.
- Split('.', ',', ':', ';', '(', ')', '[',
- ']', '"', '\'', '\\', '/', '!', '?', ' ')
- .ToList();
- while (words.Count>0)
- {
- var length = words.Sum(word => word.Length);
- var minPower = words.Min(
- word => (double)word.Sum(letter => letter) / length
- );
- var minWord = words.Single(word =>
- (double)word.Sum(letter => letter) / length == minPower
- );
- Console.WriteLine(minWord);
- words.Remove(minWord);
- Console.WriteLine(String.Join(" ", words));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement