Maria's Puzzle Book Reloaded [Puzzle 26]

good point midsummer.
@VyseGolbez what country are they in?

They are in England, so working with english numbers is what I want you to do. So no, @midsummer , Carl Friedrich did not do the excercise in finnish.

dammit, if he’d have said UK instead of england we could’ve tried in welsh

Ah well…

Okay I tried to do something, the amout of numbers with the same letters
From 100-199 = 9 (the sum is 1358)
From 1000-1999 = 90 (the sum is 135080)
So I guess 10000-19999 the sum will be 1350080
but
From 200-299 = 9 (the sum is 2312)
From 2000-2999 = 90 (the sum is 225620)

Another fun thing
From 200-299 (the sum is 2312)
From 300-399 (the sum is 3212)
the difference is 900
From 2000-2999 (the sum is 225620)
From 3000-3999 (the sum is 315620)
the difference is 90k

So there is a pattern i guess

Okay I think the easiest way here is building the progressions and finding the sum

For example from
10000-19999
10002 10022 10032 10042 10052 10062 10072 10082 10092
10102 10122 10132 10142 10152 10162 10172 10182 10192
difference between 2 rows is exactly 900
so we have 9 numbers in each column and we have to do like 100 rows of combinations so 900 numbers
Sn = ((a1+an)/2) * n
so we have S900 = ((90458 (sum of first row) + 899558)/2) * 900 = 445507200
a900=90458+900 * 899

I tried to count everything this way but I might have made a mistake somewhere I got
4173392237302

Actually I remembered that 11000 is eleven thousand so this method wont apply for 10000-19999 but I think it works for other big numbers

Recounted again and got 4414488098580

(Vyse say something… :blushing:)

Both are wrong.

:mii:but do you really know

Yes.

Is using programming to solve the puzzle allowed?

Yes, that would basically be doing it the brute force way, although I’ll tell you that it is not required.

import inflect

p = inflect.engine()
sum = 0

for i in range(1,1000001):
  word = p.number_to_words(i)
  if word[0] is word[-1]:
    sum += i
    print(word)

print(sum)

The answer would be 55862927592.

You can try it out in https://repl.it/languages/python3

so in python strings wrap around immediately, causing word [-1] to be the last letter?

Python indexing allows negative numbers to represent indices from the end of the array. So, -1 is the last index, -2 is the second-last, and so on. Applies to all arrays.

sum += i

?

It is a shorthand for “sum = sum + i”.

Yes, but wouldn’t that increase the sum by 19 for the number “19” instead of actually just counting them?

@Karifean

oh, I thought to count them for some reason. Good thing I didn’t tackle this puzzle, heh.

Anyway, the logic checks out, I must have made a mistake when calculating myself, as I’m 9000 something of your result, @midsummer. But, for the others, @King_Titanite_XV already lined out a way to systematically find all numbers that start with the same letter that they end on. What one can do now is proceed letter by letter. So for example for the letter N there’s all numbers that look like so: 19, 97, 9y7, 91z, 9xy7, 9x1z, 19xy7, 19x1z, 9xxy7, 9xx1z, 9xxxy7, 9xxx1z. x standing for any single digit, y standing for any single digit except 1 and z standing for any single digit except 2.

So let’s start with 9y7. There are basically 9 different numbers here, 907, 927, 937, 947, 957, 967, 977, 987, 997. So what one can do is calculate 907*9 and then add the loose change, so to speak, so 20+30+40+50+60+70+80+90=440. So that would be 8603, added together.

Now let’s look at one of the bigger ones, 9xy7 for example. Let’s ignore the y for now and treat that as a single digit for now. So we have to deal with that x now. this x can basically be 10 different digits, so we again multiplicate the base number, this time 9007, with ten and then add the loose change from the x on top of that. This loose change from any number of x-es can be done with the Gauß-formula, since we are basically adding consecutive numbers starting at 1. For those unfamiliar with that formula, it’s this here:
comic009
Since our x (or later, number of x-es) ends at the hundreds digit, we have to multiplicate the result with 100 before we add it. Now, with the y we deal similarly to how we dealt before, so we multiplicate our result we currently have with 9 and add 44 (adding 2 to 9) * 10 (since the y is at the tens digit) * 10 (since we have to add the second lose change 10 times because we multiplicated the base number with ten before doing anything else).

This is the basic principle that can be used for all numbers and I should have ended up with the same result as @midsummer there.

1 Like