Problem 40

completed December 6, 2011

Comments

Dealing with turning numbers into their digits and if those digits have quotes around them, and commas, and brackets, etc is really annoying. It takes so much trial and error.

Code

def str2num(n):
	return ''.join(map(str, n))
	
import re
def num2str(n):
	return re.split('_', re.sub('\B', '_', str(n)))

decimal = []
for n in range(10**6):
	n = num2str(n)
	for i in n:
		decimal.append(i)

product = 1
for n in range(7):
	product = product * int(decimal[10**n])
	
print product