In [1]:
from PIL import Image
import numpy as np
In [2]:
im = Image.open('taiwan.png')
In [3]:
arr = np.array(im.convert('L').resize((87,34)))
In [4]:
s = ""
for i in range(0,arr.shape[0]-1):
    s0 = "".join("0" if x else "1" for x in arr[i][25:-25]>5)
    s +=s0
    print(s0)
    W=len(s0)
1111111111111111111111111111111111111
1111111111111111111111111111111111111
1111111111111111111111111000011111111
1111111111111111111111100000000011111
1111111111111111111000000000000000011
1111111111111111000000000000000000111
1111111111111110000000000000000000111
1111111111111100000000000000000000111
1111111111110000000000000000000000111
1111111111000000000000000000000000111
1111111111000000000000000000000011111
1111111110000000000000000000000111111
1111111000000000000000000000000111111
1111110000000000000000000000000011111
1111000000000000000000000000000111111
1100000000000000000000000000001111111
1100000000000000000000000000001111111
1100000000000000000000000000011111111
1100000000000000000000000000011111111
1100000000000000000000000000111111111
1000000000000000000000000001111111111
1000000000000000000000000111111111111
1110000000000000000000001111111111111
1111100000000000000000111111111111111
1111100000000000000011111111111111111
1111111000000000000111111111111111111
1111111110000000000111111111111111111
1111111111110000001111111111111111111
1111111111111000001111111111111111111
1111111111111100001111111111111111111
1111111111111100000111111111111111111
1111111111111111111111111111111111111
1111111111111111111111111111111111111
In [5]:
import gmpy2
In [6]:
n = int(s, 2)
n = n+1-n%2
gmpy2.is_prime(n)
Out[6]:
False
In [7]:
for i in range(len(s)-2,0,-1):
    if s[len(s)-1-i-1]!=s[len(s)-1-i+1]: # try to change edge only(if not working, comment this line and try again)
        p = n^(1<<i)
        if gmpy2.is_prime(p):
            print(i)
            print(p)
            break
else:
    print("not working!!!!")
    
1118
36109768628918289680181237269982326836315074390373762690444804688288262200027575252299763365131812306962690821804162221273208578541930369442412178452513756440140615861198776649031195773677731825752932990810189456101069051485444236446603538346051632222803884808461872785387210706073401343398461887943541836836797791233492039274922571561154870557915420355535324418408447
In [8]:
s2 = bin(p)[2:]
s2 = '0'*(len(s)-len(s2))+s2
s2
Out[8]:
'111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111110000000001111111111111111111111110000000000000000111111111111111111000000000000000000111111111111111111000000000000000000011111111111111111000000000000000000001111111111111110000000000000000000000111111111111100000000000000000000000011111111111110000000000000000000000111111111111110000000000000000000000111111111111100000000000000000000000011111111111100000000000000000000000000111111111000000000000000000000000000111111110000000000000000000000000000111111111000000000000000000000000000011111111100000000000000000000000000011111111110000000000000000000000000001111111111000000000000000000000000001111111111000000000000000000000000001111111111100000000000000000000000011111111111111100000000000000000000011111111111111111100000000000000000111111111111111111110000000000000001111111111111111111111110000000000001111111111111111111111111110000000000111111111111111111111111111111000000111111111111111111111111111111110000011111111111111111111111111111111100001111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
In [9]:
n = int(s2, 2)
gmpy2.is_prime(n)
Out[9]:
True
In [10]:
for i in range(0,len(s2),W):
    print(s2[i:i+W])
1111111111111111111111111111111111111
1111111111111111111111111111111111111
1111111111111111111111111000111111111
1111111111111111111111100000000011111
1111111111111111111000000000000000011
1111111111111111000000000000000000111
1111111111111110000000000000000000111
1111111111111100000000000000000000111
1111111111110000000000000000000000111
1111111111000000000000000000000000111
1111111111000000000000000000000011111
1111111110000000000000000000000111111
1111111000000000000000000000000111111
1111110000000000000000000000000011111
1111000000000000000000000000000111111
1100000000000000000000000000001111111
1100000000000000000000000000001111111
1100000000000000000000000000011111111
1100000000000000000000000000011111111
1100000000000000000000000000111111111
1000000000000000000000000001111111111
1000000000000000000000000111111111111
1110000000000000000000001111111111111
1111100000000000000000111111111111111
1111100000000000000011111111111111111
1111111000000000000111111111111111111
1111111110000000000111111111111111111
1111111111110000001111111111111111111
1111111111111000001111111111111111111
1111111111111100001111111111111111111
1111111111111100000111111111111111111
1111111111111111111111111111111111111
1111111111111111111111111111111111111
In [ ]: