-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPE035.py
50 lines (45 loc) · 1.2 KB
/
PE035.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from PEtools import *
# primes = PEfindPrimesUntil(999998)
total = []
# 3-6 digits from:
# 1379
digits = ('1','3','7','9')
# and every number must have either 1 or 7
# But I didn't need to check this
current = [0,0,0]
total = 13
primes = []
ln = len(current)
while ln < 7:
primes = []
while True:
# logic
candidate = ''
for d in current:
candidate += digits[d]
# print(candidate)
candcopy = candidate
if candcopy not in primes:
pr = True
tempprimes = []
while PEisPrime(int(candcopy)):
tempprimes.append(candcopy)
candcopy = candcopy[1:] + candcopy[0]
if candcopy == candidate:
break
if candcopy == candidate:
primes += tempprimes
lc = len(current)
for dind in range(lc):
# print('current', current)
if current[dind] == 3:
current[dind] = 0
else:
current[dind] += 1
break
if sum(current) == 0:
total += len(primes)
current.append(0)
ln += 1
break
print(total)