Large Numbers Arranged Alphabetically

Logic Level 5

Imagine a list of all numbers from 1 1 to 1 0 100 10^{100} arranged in alphabetical order. If all numbers smaller than 1 0 20 10^{20} are removed from the list, what is the 1 5 th 15^\text{th} number ( ( call it N ) N) on the list?

Enter the value of N N as the sum of the product of each digit multiplied by the place of the digit in the number from right to left. For example, If N = 348 N = 348 , enter your answer as 8 × 1 + 4 × 2 + 3 × 3 = 25. 8 \times 1 + 4 \times 2 + 3 \times 3 = 25.

Clarifications:

  • Numbers are written in this word format: four billion six million forty-eight , one million one .
  • Ones must be added in front of numbers: hundred cannot be written, but one hundred .
  • Do not use phrases like eighteen hundred , but one thousand eight hundred .
  • Shorter words come before longer words when one number includes the other at the start: three comes before three thousand .
  • Ignore spaces and hyphens.
  • The short scale naming system of numbers is used, meaning the following numbers have the following names:
1 0 n 10^{n} Name 1 0 n 10^{n} Name 1 0 n 10^{n} Name
6 million 39 duodecillion 72 trevigintillion
9 billion 42 tredecillion 75 quattuorvigintillion
12 trillion 45 quattuordecillion 78 quinvigintillion
15 quadrillion 48 quindecillion 81 sexvigintillion
18 quintillion 51 sexdecillion 84 septenvigintillion
21 sextillion 54 septendecillion 87 octovigintillion
24 septillion 57 octodecillion 90 novemvigintillion
27 octillion 60 novemdecillion 93 trigintillion
30 nonillion 63 vigintillion 96 untrigintillion
33 decillion 66 unvigintillion 99 duotrigintillion
36 undecillion 69 duovigintillion 102 tretrigintillion


The answer is 473.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Ron Lauterbach
Oct 31, 2017

The list will look like this:

01 eight decillion

02 eight decillion eight

03 eight decillion eight billion

04 eight decillion eight billion eight

05 eight decillion eight billion eighteen

06 eight decillion eight billion eighteen million

07 eight decillion eight billion eighteen million eight

08 eight decillion eight billion eighteen million eighteen

09 eight decillion eight billion eighteen million eighteen thousand

10 eight decillion eight billion eighteen million eighteen thousand eight

11 eight decillion eight billion eighteen million eighteen thousand eighteen

12 eight decillion eight billion eighteen million eighteen thousand eighty

13 eight decillion eight billion eighteen million eighteen thousand eighty-eight

14 eight decillion eight billion eighteen million eighteen thousand eighty-five

15 eight decillion eight billion eighteen million eighteen thousand eighty-four

4 × 1 + 8 × 2 + 8 × 4 + 1 × 5 + × 7 + 1 × 8 + 8 × 10 + 8 × 34 = 473 4 \times 1 + 8 \times 2 + 8 \times 4 + 1 \times 5 + \times 7 + 1 \times 8 + 8 \times 10 + 8 \times 34 = \boxed{473}

Isn't eight decillion (8*10^33) greater than 10^20? All numbers greater than 10^20 are removed from the list.

Also, the list should start with "Eight".

Greg Whiteside - 3 years, 7 months ago

Log in to reply

It meant to say smaller... I am sorry.

Ron Lauterbach - 3 years, 7 months ago

Log in to reply

It is now fixed.

Ron Lauterbach - 3 years, 7 months ago

Log in to reply

@Ron Lauterbach Why does your eighty with a Y comes before eight hundred with an H? You said to ignore the spaces and symbols, right? Shouldn't it be eighteen (E) --> eight hundred (H) --> eight million (M) --> eight thousand (T) --> eighty (Y)

Saya Suka - 2 years, 1 month ago

No problem. That is a much more interesting problem now.

Greg Whiteside - 3 years, 7 months ago

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 02 17:01:50 2017

@author: Michael Fitzgerald
"""

power_of = {'hundred':[3], 'thousand':[4,5,6],'million':[7,8,9], 'billion':[10,11,12], \
    'trillion':[13,14,15], 'quadrillion':[16,17,18], 'quintillion':[19,20,21], \
    'sextillion':[22,23,24], 'septillion':[25,26,27], 'octillion':[28,29,30], \
    'nonillion':[31,32,33], 'decillion':[34,35,36], 'undecillion':[37,38,39],  \
    'duodecillion':[40,41,42],'tredecillion':[43,44,45], 'quattuordecillion':[46,47,48], \
    'quindecillion':[49,50,51], 'sexdecillion':[52,53,54], 'septendecillion':[55,56,57], \
    'octodecillion':[58,59,60], 'novemdecillion':[61,62,63], 'vigintillion':[64,65,66], \
    'unvigintillion':[67,68,69], 'duovigintillion':[70,71,72], 'trevigintillion':[73,74,75], \
    'quattuorvigintillion':[76,77,78], 'quinvigintillion':[79,80,81], 'sexvigintillion':[82,83,84], \
    'septenvigintillion':[85,86,87], 'octovigintillion':[88,89,90], 'novemvigintillion':[91,92,93], \
    'trigintillion':[94,95,96], 'untrigintillion':[97,98,99], 'duotrigintillion':[100,101,102], \
    'tretrigintillion':[103,104,105] }

units = {0:'', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five', \
    6:'six', 7:'seven', 8:'eight', 9:'nine'}
teen_units = {0:'ten', 1:'eleven', 2:'twelve', 3:'thirteen', 4:'fourteen', \
    5:'fifteen', 6:'sixteen', 7:'seventeen', 8:'eighteen', \
    9:'nineteen'}
tens = {0:'', 1:'', 2:'twenty', 3:'thirty',  4:'forty', 5:'fifty', \
    6:'sixty', 7:'seventy', 8:'eighty', 9:'ninety'}
hundreds = {0:'', 1:'one hundred', 2:'two hundred', 3:'three hundred', \
    4:'four hundred', 5:'five hundred', 6:'six hundred', \
    7:'seven hundred', 8:'eight hundred', 9:'nine hundred'}

limit = 20  #  "10 to the power of" limit , <------------------------------------------------enter value


print 'First word printed alphabetically\n'
t = units.values()
for i in range(len(teen_units)):
    t.append(teen_units[i])
for i in range(len(tens)):
    t.append(tens[i])

t =' '.join(t).split()   
t = sorted(t)    
for i in range(len(t)):
    print t[i]


print '\nSecond word printed alphabetically'
print '"xxxxx" means is below limit of 10^%d and not included in second word\n' % limit
alph =sorted(power_of.keys())
alph = ' '.join(alph).split()   # Remove ''s
for i in range(len(alph)):
    print '\n%s' % alph[i],
    if max(power_of[alph[i]]) < limit:
        print '\t\t\t\txxxx',


print '\n\n\n'
#                                                                                                               X <- ^100
num_alph_all = []
for j in range(99999999999999999999, \
               100000000000000000001):

    num = str(j)
    teens = False
    ten_flag = False
    #print
    list_ = []
    num_alph = ''


    for k in range(len(num),0,-1):
        if int(num[len(num)-k]) > 0:
            list_.append(k)

    for i in range(len(num),0,-1):              
        if i%3 == 0:
            if hundreds[int(num[len(num)-i])] <> '':
                num_alph = " ".join((num_alph, hundreds[int(num[len(num)-i])]))
        if i%3 == 2:
            # ten (1 and 0) is a special case; add entry to list_ to lower min(y) by 1            
            if (int(num[len(num)-i]) == 1) and (int(num[len(num)-i+1]) == 0):
                list_.append(i-1)                               
            if int(num[len(num)-i]) >= 2:
                if tens[int(num[len(num)-i])] <> '':
                    num_alph = " ".join((num_alph, tens[int(num[len(num)-i])]))
            elif int(num[len(num)-i]) == 1:
                teens = True               
        if (i%3 == 1) and (teens == True):
            if teen_units[int(num[len(num)-i])] <> '':
                num_alph = " ".join((num_alph, teen_units[int(num[len(num)-i])]))
            teens = False
        elif (i%3 == 1) and (teens == False):             
            if units[int(num[len(num)-i])] <> '':
                num_alph = " ".join((num_alph, units[int(num[len(num)-i])]))

        if i in list_:           
            for key, val in power_of.iteritems():
                if i in val:
                    y = list(set(list_) & set(val))
                    if (i == min(y)):
                        num_alph = " ".join((num_alph, key))
        if i == 1:
            num_alph = num_alph[1:]
            num_alph_all.append(num_alph)

y = sorted(num_alph_all)
for i in range (len(y)):
    print y[i]



###############################################################################     

Michael Fitzgerald - 3 years, 7 months ago

Log in to reply

Sorry, but how did you make this menu?

Ron Lauterbach - 3 years, 7 months ago

This is nice, but you have to consider 3 things: 1) You have to combine the names of the longer numbers. For example: trillion billion 2) You have to add a number (under 1000) in front of each of these long numbers. For example: four trillion six billion 3) If the number is not divisible by 1000 and doesn't have 3 non-zero ending digits, you have to be careful with the ending. four trillion six billion fourty-six

The algorithm below could work:

First Step As you don't want to go through all 1 0 100 1 0 20 10^{100} - 10^{20} numbers you could make an algorithm like this: First the first number under thousand. --> 8 Then find the first bigger number over 1 0 20 10^{20} . --> decillion Combine these and you have number 1. As you will have to have another number under 100 next, repeat the 8. Now add the first large number smaller than a decillion. --> billion Repeat until you have already used a million. You now have: eight decillion eight billion eighteen million eight

Second Step (done after first) Now look for all numbers, that start with 8 and are under a million. The first (alphabetically) is 18. Now add the last remaining term --> thousand Repeat, but instead of having the constraint "under a million" you now each time have the constraint smaller than the last number (thousand) Repeat until there are no more numbers to continue. You are now here: eight decillion eight billion eighteen million eighteen thousand eighteen Now remove 1 character and repeat the second step (I mean the algorithm, which we just did, there is no name). If there are still no results continue removing a character and repeating the algorithm. After removing e, e and n you find eighty as first next possible outcome. To which you can append 8. Now redo the removing and find 85 and 84. Done, 15 elements found. (You could find more, but it would be enough for this problem.)

Ron Lauterbach - 3 years, 7 months ago

Log in to reply

Totally. I got the logic I just tried to script it so any 10^x could be evaluated in the range 10^100. Also, I thought it would be neat to add a pythonic solution

Michael Fitzgerald - 3 years, 7 months ago

Log in to reply

@Michael Fitzgerald last two lines, in this case, show the number output alphabetically for range in question

1
2
for j in range(99999999999999999999, \
               100000000000000000001):

Michael Fitzgerald - 3 years, 7 months ago

This script I created will sort numbers alphabetically and write numbers in a provided range alphabetically.

Michael Fitzgerald - 3 years, 7 months ago

How can I forget eighteen? Duh > _ <

Afkar Aulia - 2 years, 5 months ago

Why does your eighty with a Y comes before eight hundred with an H? You said to ignore the spaces and symbols, right? Shouldn't it be eighteen (E) --> eight hundred (H) --> eight million (M) --> eight thousand (T) --> eighty (Y)

Saya Suka - 2 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...