Speeding up Project Euler 43 - sub-string divisibility
You can make a few quick improvements without altering the algorithm significantly:


Remove one of the redundant calls to timer().
Store the list of primes instead of calculating it for every call to follows_property.
Convert the digits to strings in the list passed to permutations so you can simplify the calculation of num.
Run through all permutations instead of 9-tuples and remove the Counter and missing parts.


These are minor changes, but they clean up the code a bit. I also renamed ans to sum to clarify what it holds. They also cut the running time by more than half.

from itertools import permutations
from primes import primes_upto
from collections import Counter
from timeit import default_timer as timer

divisors = primes_upto(17)

def follows_property(n):
    for k in range(7):
        if int(n[k+1:(k+4)]) % divisors[k] != 0:
            return False
    return True

sum = 0
start = timer()

for combo in permutations([str(x) for x in range(10)]):
    num = ''.join(combo)
    if follows_property(num):
        sum += int(num)

elapsed_time = (timer() - start) * 1000 # s --&gt; ms

print("Found %d in %r ms." % (sum, elapsed_time))