Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import combinations
- def replace(n):
- n, original = str(n), str(n)
- indexes = []
- for w in range(len(n)-1):
- indexes.append(w)
- combos = list(combinations(indexes, 3))
- for x in combos:
- if not n[x[0]] == n[x[1]] == n[x[2]]:
- continue
- else:
- total = 0
- nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- temp = []
- for y in n:
- temp.append(y)
- for z in nums:
- temp[x[0]] = str(z)
- temp[x[1]] = str(z)
- temp[x[2]] = str(z)
- check = int("".join(temp))
- if len(str(check)) < len(temp):
- continue
- if check in primes:
- total += 1
- print(total)
- if total == 8:
- print(original)
- quit()
- def primes_sieve(limit):
- a = [True] * limit
- a[0] = a[1] = False
- for (i, isprime) in enumerate(a):
- if isprime:
- yield i
- for n in range(i*i, limit, i):
- a[n] = False
- primes = list(primes_sieve(10**8))
- for b in primes:
- print(b)
- if b < 1000:
- continue
- replace(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement