Project Euler 51 - Prime Digit Replacements

Official link: https://projecteuler.net/problem=51

Thought Process

2 major hints to this problem are:

  1. We only need to deal with primes

  2. Some Modular Arithmetic can make this problem much easier. See the reasoning below

In short generate a list of primes less than a big enough number (I started with 10,000,000), filter that list to include only primes which have 3 repeated digits, then go through your new list and replace the 3 times repeated digit to every digit (Use the str.replace() function in python for this!), check if it's prime, if you find a family of 8 stop.

Prime generator and is_prime function are in my Essential Functions

Interactive Code

Please input 2 integer's (x, y)

Code will output the smallest prime where by replacing y digits forms a family of length x

Example: Input = 7 2 : Output = 56003