## [Problem 51](https://projecteuler.net/problem=51)
Prime digit replacements


```python
from sympy import sieve
import numpy as np
```


```python
N=6
primes=[i for i in sieve.primerange(10**(N-1),10**N)]
#1を3回使うものの桁
diffs=[(k,j,i) for i in range(1,N) for j in range(i+1,N) for k in range(j+1,N)]
```


```python
intersections=[]
for diff_kji in diffs:
    k,j,i=diff_kji
    diff=10**k+10**j+10**i
    prime_list=[_i for _i in primes if str(_i)[N-k-1]==str(_i)[N-j-1]==str(_i)[N-i-1]]
    prime_set=set(prime_list)
    prime_array=np.array(prime_list)
    #3連続は絶対にあるはず
    #intersection=[[{_i,_i+diff,_i+2*diff},[int(_k) for counter,_k in enumerate(str(_i)) if 6-counter-1 not in {k,j,i}]] for _i in prime_list if {_i,_i+diff,_i+2*diff} <= prime_set]
    ketas=[N-counter-1 for counter in range(N) if N-counter-1 not in {k,j,i}]
    intersection=[[int(_k) for counter,_k in enumerate(str(_i)) if N-counter-1 not in {k,j,i}] for _i in prime_list if {_i,_i+diff,_i+2*diff} <= prime_set]
    possibles=[10**ketas[0]*_i[0]+10**ketas[1]*_i[1]+10**ketas[2]*_i[2] for _i in intersection]
    possibles=[set([possible+_i*diff for _i in range(10)]) for possible in possibles]
    for p in possibles:
        if len(p & prime_set)==8:
            print(p & prime_set)
```

    {121313, 323333, 525353, 929393, 222323, 424343, 626363, 828383}
    {121313, 323333, 525353, 929393, 222323, 424343, 626363, 828383}
    {121313, 323333, 525353, 929393, 222323, 424343, 626363, 828383}
    {121313, 323333, 525353, 929393, 222323, 424343, 626363, 828383}


## [Problem 53](https://projecteuler.net/problem=53)
Combinatoric selections


```python
import numpy as np
```


```python
dp=[[1]]
for n in range(1,101):
    l=[1]
    for r in range(1,n):
        l.append(dp[n-1][r-1]+dp[n-1][r])
    l.append(1)
    dp.append(l.copy())
```


```python
ans_list=[1 for l in dp for x in l if x>10**6]
print(len(ans_list))
```

    4075



```python

```

2ffc387529d5c1602e49b8284d320e69910fadf0
ipynb
Jupyter Notebook
p051-060.ipynb
yonesuke/ProjectEuler
6001713b1ffb0e83431d6fae6d3ac081b843e432
MIT
2019-09-06T18:49:09.000Z
2019-09-06T18:49:09.000Z
p051-060.ipynb
yonesuke/ProjectEuler
6001713b1ffb0e83431d6fae6d3ac081b843e432
MIT
p051-060.ipynb
yonesuke/ProjectEuler
6001713b1ffb0e83431d6fae6d3ac081b843e432
MIT
Qwen/Qwen-72B
1. YES
2. YES