simplify code a bit
This commit is contained in:
parent
0ce65b7a39
commit
0773e06401
|
@ -37,13 +37,14 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from itertools import combinations\n",
|
||||
"\n",
|
||||
"progressions = set()\n",
|
||||
"for (i, p) in enumerate(sorted(primes)):\n",
|
||||
" for q in primes[i+1:]:\n",
|
||||
" d = q - p\n",
|
||||
" r = q + d\n",
|
||||
" if r < 10000 and is_prime(r):\n",
|
||||
" progressions.add((p, q, r))"
|
||||
"for (p, q) in combinations(primes, 2):\n",
|
||||
" d = q - p\n",
|
||||
" r = q + d\n",
|
||||
" if r < 10000 and is_prime(r):\n",
|
||||
" progressions.add((p, q, r))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -101,13 +102,11 @@
|
|||
}
|
||||
],
|
||||
"source": [
|
||||
"from collections import Counter\n",
|
||||
"\n",
|
||||
"for (p, q, r) in progressions:\n",
|
||||
" if p == 1487 and q == 4817 and r == 8147:\n",
|
||||
" continue\n",
|
||||
" \n",
|
||||
" if Counter(p.digits()) == Counter(q.digits()) == Counter(r.digits()):\n",
|
||||
" if sorted(p.digits()) == sorted(q.digits()) == sorted(r.digits()):\n",
|
||||
" break\n",
|
||||
" \n",
|
||||
"p, q, r"
|
||||
|
|
Loading…
Reference in New Issue