### Problem:

By replacing the 1^{st} digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.

By replacing the 3^{rd} and 4^{th} digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003, 56113, 56333, 56443, 56663, 56773, and 56993. Consequently 56003, being the first member of this family, is the smallest prime with this property.

Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime value family.

**********

The string.replace(old, new) method made this solution work.

### One Possible Solution:

# Python version = 2.7.1 # Platform = win32 import gmpy import string def isprime(n): """Return True of False - Prime number""" if gmpy.is_prime(n): return True else: return False def prime_list(): """Create prime number list below 1000000""" L = [] for n in xrange(100, 1000000): if isprime(n): L.append(n) return L def replace(s1, n): """Replace repeating digits""" L1 = [] for i in range(1, 10): y = str(i) x = s1.replace(n, y) L1.append(x) return L1 def are_prime(x): """Check new number for primality""" L2 = [] for number in x: if isprime(int(number)): L2.append(int(number)) else: continue if len(L2) == 8: print "L2 = ", L2 print "YAHOOOO!" return True def call_this(s1, k): """Intermediate step""" for n in s1: if n == k: x = replace(s1, n) if are_prime(x): return True def find_duplicates(prime): """Find digits that repeat""" s = '' s1 = str(prime) s = s1[0:-1] d = {} for i in s: # Create Dictionary d[i] = s.count(i) for k, v in d.items(): if v > 1: if call_this(s1, k): break else: continue def main(): """Main Program""" x = prime_list() for prime in x: y = find_duplicates(prime) if __name__ == '__main__': main()