#word problem, but first: why I’m an idiot:

So I’ve been working on this little puzzle:

“If the integers from 1 to 999,999,999 are written as words, sorted alphabetically, and concatenated, what is the 51 billionth letter?” from ita software

I outlined the framework of an algorithmic solution months ago when I first saw it, and i solved it with maple, but never got to implement it using a ‘proper’ programming language.

This problem came to mind again recently as a fun excuse to get my hands dirty with a computer programming language called python.

I’ll start at the end, and say I was totally frustrated, because my seemingly perfect algorithm gave the wrong answer, in spite of passing all sorts of verification tests… I finally got to the point I was so convinced that unless I failed to spell the 27 numbers in my native language’s naming scheme, the problem’s hint must have been wrong…. >>>

google

so 40 is ‘forty’, not ‘fourty’.  and then everything worked perfectly…

Read the rest of this entry »