@@ -0,0 +1,1636 @@
+'''%0AProblem 017%0A%0AIf the numbers 1 to 5 are written out in words: one, two, three, four, five, %0A  then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.%0A%0AIf all the numbers from 1 to 1000 (one thousand) inclusive were written out in %0A  words, how many letters would be used?%0A%0A%0ANOTE: Do not count spaces or hyphens. For example, 342 (three hundred and %0A  forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 %0A  letters. The use of %22and%22 when writing out numbers is in compliance with %0A  British usage. %0A%0A%0ASolution: Copyright 2017 Dave Cuthbert, MIT License%0A'''%0A%0Aones_names = %5B'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',%0A              'eight', 'nine', 'ten', 'eleven',  'twelve', 'thirteen',%0A              'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen',%0A              'nineteen'%5D%0A              %0Atens_names = %5B'zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty',%0A              'seventy', 'eighty', 'ninety'%5D%0A%0A%0Adef build_words(n):%0A    if n == 1000:%0A        return 'one' + 'thousand'%0A    elif n %3E 99:%0A        hundreds = ones_names%5Bint(n / 100)%5D + 'hundred'%0A        n = n %25 100%0A        if n == 0:%0A            return hundreds%0A        return hundreds + 'and' + build_words(n)%0A    elif n %3E 19:%0A        tens = tens_names%5Bint(n / 10)%5D%0A        n = n %25 10%0A        if n == 0:%0A            return tens%0A        return tens + ones_names%5Bn%5D%0A    else:%0A        return ones_names%5Bn%5D%0A%0A    %0A%0Adef solve_problem():%0A    total_letters = 0%0A    for n in range(1,1001):%0A        total_letters += len(build_words(n))%0A%0A%0A    return(total_letters)%0A%0A%0Aif __name__ == %22__main__%22:%0A    print(solve_problem())%0A

Solve number letter counts