# Find all numbers up to 8.1 mil with every digit in it adds up to 10 with few previous and/or next digits.

Hi everybody, I would appreciate some help with an exercise. Here it is:

There are sequences in some numbers, which adds up to 10. For example, number 3523014 you can find 4 such sequences:

3523014

3523014

3523014

3523014

We can find some 'wonderful' numbers, in which each digit is in at least one of such sequences.

For example, 3523014 is 'wonderful' number, but 28546 - is not (there is such sequence, which adds up to 10 and includes 5 at the same time).

I need to find number of such 'wonderful' numbers in interval [1, 8100000] (1 and 8100000 inclusively).

I've tried to solve it on my own using Python, but I'm quite new to programming and cannot think of algorithm, which will not give me wrong numbers among the right ones.

I don't want to mess up question, so I put actual code on pastebin:

http://pastebin.com/qcm7tPkq

​It returns wrong answers like 91846, 91855, etc.