Project Euler #111: Primes with runs

  • + 0 comments

    The crucial point here is to generate permutations without duplicates like C++ std::next_permutation(). I don't think using itertools.permutations is appropriate here. Also, skip those permutations with preceding zeros. (e.g. start with 100000000003 instead of 000000000013) Then you won't get into TLE trouble with cases like 15 0, 24 0, 31 0, 33 0, 34 0 and 35 0. And don't forget the prime .