Solved another Project Euler problem today. From the site:

An irrational decimal fraction is created by concatenating the positive integers:

0.123456789101112131415161718192021…

It can be seen that the 12

^{th}digit of the fractional part is 1.If

d_{n}represents then^{th}digit of the fractional part, find the value of the following expression.

d_{1}d_{10}d_{100}d_{1000}d_{10000}d_{100000}d_{1000000}

My original intentions were to figure out an elegant formula for deriving d_{n} given some *n*. I thought about it for a few minutes and figured it’d be interesting to see if the straight brute force solution was quick enough. So I quickly coded it up in python, and sure enough, it’s sub-second and therefore easily quick enough.

[email protected]:~/proj_euler$ time python prob40.py

210real 0m0.906s

user 0m0.724s

sys 0m0.044s

list =””

for n in range(1,1000001):

list += str(n)

answers = [list[0], list[9], list[99], list[999], list[9999], list[99999], list[999999]]

prod = 1

for n in answers:

prod = prod * int(n)

print prod