Advertisement
ksmk99

Number letter counts №17

Sep 16th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. //If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
  7.  
  8. //If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
  9.  
  10.  
  11. //NOTE: Do not count spaces or hyphens.For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters.The use of "and" when writing out numbers is in compliance with British usage.
  12.  
  13. namespace _17
  14. {
  15.     class Program
  16.     {
  17.         static void Main(string[] args)
  18.         {
  19.             string content = System.IO.File.ReadAllText(@"C:\Users\Максим\Documents\data.txt", Encoding.Default);
  20.             var a = content.Split(' ', '-');
  21.             var sum = 0;
  22.             foreach(var e in a) sum += e.Length;
  23.             Console.WriteLine(sum);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement