House Plaques

  1. Two painters are painting plaques for the numbers of the houses of Puzzle Street (which are consecutive, starting with 1.) In the time it takes the younger one to paint 4 digits, the older one paints 5 digits. The younger begins with the plaques 1, 2, 3, ... and the older with the last ones. They paint their last house plaque at the same time and each one has painted the same number of plaques. How many houses are on the street?
  2. Same question when the younger paints 5 digits for every 6 of the older.
  3. Same question when the younger paints 3 digits for every 4 of the older.
  4. Same question when the younger paints 2 digits for every 3 of the older.
Can this be generalized? If the younger paints M digits for every N of the older (M < N), can a simple formula or algorithm find the number of houses?

Source: 1. Tangente n° 67 - Gilles Cohen, Alain Fily,Dominique Souder, submitted by Philippe Fondanaiche. 2-4. Original extensions.


Solutions were received from Larry Baum, Joel D. Haywood, Denis Borris.

Joel Haywood's solution is very powerful, I feel:

Let the greatest integer greater than or equal to x be denoted [x], and let
the base 10 logarithm of x be denoted log x.

Let h be the number of houses (h > 0).  Then, the number of digits in the 
last plaque is [log h].  If the leading zeros of house numbers were included 
on the plaques to make all numbers have the same number of digits, then the 
total number of digits to be painted would be h * [log h].  Thus, the total 
number of digits to be painted is that number less all those leading zeros.  
Now, there are 9 * 10 ^ (k - 1) house numbers that have k digits, and, thus, 
[log h] - k leading zeros.  Thus, the total number of leading zeros is the 
sum from k=1 to [log h] of 9 * 10 ^ (k - 1) * ([log h] - k).  Denote this sum 
as S(h).  Thus, the total number of digits to be painted is h * [log h] - 
S(h).  Denote this number as d(h).

Since each painter paints the same number of plaques, each painter paints h / 
2 plaques.  Thus, the younger paints d(h / 2) digits and the older paints 
d(h) - d(h / 2) digits.  Since each finishes painting at the same time, d(h / 
2) / M = {d(h) - d(h / 2)} / N.  Thus, (M + N) * d(h / 2) = M * d(h).  Thus, 
a solution to the problem is an integral solution to this equation.

To solve the equation, note that every value of h falls into one of two 
catagories:  [log h] = [log (h / 2)] or [log h] = [log (h / 2)] + 1.  By 
dividing into each case and checking individual values of [log h], an attempt 
at finding solutions can be made.

Now, for the POTW.  If [log h] = [log (h / 2)], then the above equation can 
be reduced to h = 2 * N * S(h) / {(N - M) * [log h]}.  Consider 200 <= h < 
1000.  Then, 3 = [log h] = [log (h / 2)] and S(h) = 108.  Thus, h = 72 * N.  
Thus, there will be such a solution for 3 <= N <= 13.  Thus, one solution to 
each part is 360, 432, 288, and 216, respectively.

Now, consider 20 <= h < 100.  Then, 2 = [log h] = [log (h / 2)] and S(h) = 9. 
 Thus, h = 9 * N.  Thus, there will be such a solution for 3 <= N <= 11.  
Thus, another solution to each part is 45, 54, 36, and 27, respectively.  Of 
course, for an odd number of houses, this assumes that each painter paints 
one of the two digits of the "center" plaque.

Denis Borris' solution is of course very thorough and entertaining:
SOLUTION:
Here's a chart for all ratios under 10,
including answers to first 4 questions:
    RATIO            LAST
  Fast Slow         street#
    2    1             18
    3    2             12
         2            216
    4    3             36
         3            288
         3          1,710
         3          2,214
    5    4            360
         4         22,212
    6    3             18
         4            216
         5             10
         5             54
         5            432
         5          1,242
         5        222,210
    7    5            144
         5            252
         6            504
         6          1,164
         6      2,222,208
    8    5             24
         6            288
         7             72
         7            576
         7          4,428
         7        135,810
         7        296,280
         7     22,222,206
    9    6             12
         6            216
         7            324
         8            648
         8          1,080
         8     15,555,568
         8    222,222,204
(I will be forwarding this chart to all major cities,
 care of Maintenance Dept, House Number Painting Div!)


General Case formula(s)
=======================
Hard to be brief here, but I'll try!
Let:
G = Group (1-9: G=1, 10-99: G=2, ...);
    so G = number of digits of a number in the Group.
N = G-1 ; easier to type 10^N than 10^(G-1)!
L = Low  ratio number (slow painter : sp)
H = High ratio number (fast painter : fp)

Brief analysis:
- total Plaques = last number on street
- last no. on street = twice the number sp ends at
- sp starts at 1 and ends in Group G
- 2 possibilities exist for each Group G
- Case 1: fp starts and ends in Group G
- Case 2: fp starts in Group G+1, ends in Group G

I'll use G=3, H=4 and L=3 to illustrate, 
which contains 2 solutions, 288 and 1710:

CASE 1
======
           10^N-1       P         2P            10^G-1
(1).........(99).......144.......288............(999)....
Digits:    D=189      X=324     Y=432

 D = total digits from 1 to end of Group N (see ** below)
 X = total digits painted by sp
 Y = total digits painted by fp
Then:
 X = D + G * (P - 10^N + 1)
 Y = G * P
Apply ratio:
 H * X = L * Y ; substitute to get the formula for Case 1:
 
 P = [H * G * (10^N - 1) - H * D] / [G * (H - L)] 
(double to get last street number) 
** where: D = G * 10^G - INT(7/63 * 10^G)
...funny looking but works!

Case 2
======
           10^N-1       P       10^G-1              2*P
(1).........(99).......855......(999)...............1710....
Digits:    D=189     X=2457                        Y=3276
SO:
X = D + G * (P - 10^N + 1)    (same as Case 1)
Y = G * (10^G - 1 - P) + (G + 1) * (2 * P - 10^G + 1)
(quite a bit more complicated than in Case 1!)

Again, applying ratio:
H * X = L * Y ; substitute to get the formula for Case 2:

P = [L * (10^G - 1) - H * G * (10^N - 1) + H * D] / [L * (G + 2) - H * G]

(H * G < L * (G + 2)
(double to get last street number)
again, where D = G * 10^G - INT(7/63 * 10^G)
   
TO: Philippe Fondanaiche
Nice casse-tete, mon ami :>)

Mail to Ken