summaryrefslogtreecommitdiff
path: root/060.py
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:21:45 +0200
committerReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:35:09 +0200
commit95341b61b030c9e1290f3b326cb7ec584f543aea (patch)
tree852386fa04d32eb859bca11c0eff7b5ef9e50f00 /060.py
parent571164d977f91925c4c76a292f74f5f93d09ae23 (diff)
moved files to higher directory after split to new repositoryHEADtrunk
Diffstat (limited to '060.py')
-rw-r--r--060.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/060.py b/060.py
new file mode 100644
index 0000000..22d1311
--- /dev/null
+++ b/060.py
@@ -0,0 +1,49 @@
+from common import sieve
+
+#
+# WARNING: uses a lot of RAM!
+#
+# notes:
+# - limit:1000000, sieve:50000000 -> no result when starting with ["3"] or ["7"]
+# - limit:800000, sieve:50000000 -> no result!
+# - limit:100000, sieve:100000000 -> [['13', '5197', '5701', '6733', '8389']]
+#
+#
+
+limit = 9000
+
+primes = sieve(int(str(limit)+str(limit))).primes()
+prime_list = [ p for p in primes if p < limit]
+prime_list.sort()
+prime_list_str = [ str(p) for p in prime_list ]
+
+def check_list(l):
+ result = []
+ for sublist in l:
+ for p in prime_list_str:
+ isprime = True
+ for n in sublist:
+ if int(n+p) not in primes or int(p+n) not in primes:
+ isprime = False
+ break
+ if isprime:
+ result += [ sublist+[p] ]
+
+ return result
+
+
+def cleanup(l):
+ result = []
+ for sublist in l:
+ sublist.sort()
+ if sublist not in result:
+ result += [sublist]
+ return result
+
+
+l = [ [p] for p in prime_list_str ]
+for i in range(4):
+ l = cleanup(check_list(l))
+
+print l
+