from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
im = Image.open('tomkooij.png')
im.load()
<PixelAccess at 0x1e3db8d0570>
arr = np.asarray(im)
arr
array([[[142, 177, 215, 255], [142, 177, 215, 255], [142, 178, 214, 255], ..., [148, 184, 222, 255], [143, 185, 220, 255], [146, 183, 220, 255]], [[148, 184, 220, 255], [150, 187, 218, 255], [149, 185, 218, 255], ..., [144, 184, 220, 255], [140, 185, 219, 255], [145, 184, 221, 255]], [[160, 189, 220, 255], [161, 190, 222, 255], [151, 187, 214, 255], ..., [139, 183, 217, 255], [140, 183, 217, 255], [146, 183, 220, 255]], ..., [[219, 92, 135, 255], [221, 95, 137, 255], [219, 92, 135, 255], ..., [229, 132, 165, 255], [223, 123, 157, 255], [227, 117, 155, 255]], [[218, 92, 135, 255], [222, 95, 138, 255], [215, 88, 131, 255], ..., [223, 116, 152, 255], [225, 112, 151, 255], [224, 114, 151, 255]], [[221, 94, 137, 255], [220, 98, 139, 255], [222, 95, 138, 255], ..., [224, 117, 153, 255], [225, 113, 151, 255], [221, 109, 147, 255]]], dtype=uint8)
plt.imshow(arr)
<matplotlib.image.AxesImage at 0x1e3dbbc46d8>
y_size, x_size, _ = arr.shape
x_size = 79
number_grid = np.zeros((y_size, x_size))
for y in range(y_size):
for x in range(x_size):
rgb = arr[y][x]
number_grid[y][x] = sum(rgb)
number_grid[number_grid <= 500] = 1
number_grid[number_grid > 500] = 8
number_grid
array([[8., 8., 8., ..., 8., 8., 8.], [8., 8., 8., ..., 8., 8., 8.], [8., 8., 8., ..., 8., 8., 8.], ..., [8., 8., 8., ..., 8., 8., 8.], [8., 8., 8., ..., 8., 8., 8.], [8., 8., 8., ..., 8., 8., 8.]])
plt.imshow(number_grid)
<matplotlib.image.AxesImage at 0x1e3dbe75668>
number_grid.shape
(128, 79)
# shrink height: throw away every other line
number_grid = np.delete(number_grid, np.s_[::2], axis=0)
number_grid.shape
(64, 79)
def float_to_char(x):
if x > 2.: return '1'
return '8'
prime_str = ''
for line in number_grid:
l = ''.join((float_to_char(x) for x in line))
print(l)
prime_str += l
1111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111118888888888811111111111111111111111111111111 1111111111111111111111111888811111888888888888888881111111111111111111111111111 1111111111111111111118888888888888888888888888881888888111111111111111111111111 1111111111111111118888888888888888888888888888888888818881111111111111111111111 1111111111111111188888888888888888888888888888888888888181111111111111111111111 1111111111111118888888888888888888888888888888888888818881811181111111111111111 1111111111111888888888888888888888888888888888888888888118818188111111111111111 1111111111118888888888888888888888888888888888888888888811888818811111111111111 1111111111188888888888888888888888888888888888888888188888888888888811111111111 1111111111888888888888888888888888881111188888888888888188888888818181111111111 1111111111888888888888111811888811111111111111888881118888888888888888181111111 1111111118888888888811181111111111111111111111111188888888888888888888881111111 1111111188888888881111111111111111111111111111111111111118888888888888888111111 1111111888888888111111111111111111111111111111111111118188888888888888888811111 1111111888888181111111111111111111111111111111111111111111888888888888888111111 1111111888881111111111111111111111111111111111111111111111118888888888888111111 1111111188881811111111111111111111111111111111111111111111181188888888888111111 1111111188888811111111111111111111111111111111111111111181111188888888888111111 1111111188888811111111111111111111111111111111111111111111888888888888888111111 1111111188888111111111111111111111111111111111111111111111118888888888881111111 1111111118888811111111111111111111111111111111111111111811188888888888881111111 1111111118888811111111111111111111111111111111111111111111188888888888881111111 1111111111888111111111111111111111111111111111111111111111188888888888811111111 1111111111881188888888888811111111111111188888888888888111118888888888811111111 1111111111888888888888888888111111111111888888888888888888811888888888811111111 1111111118888881111888888811881111111118888188118888888888888888888888111111111 1111111888888888881188181811118881118888888181188888888888888118888888888811111 1111111188811888881111111111118111111888111111118881888888888118888818881111111 1111111111811811111111111111118111111888811111111188888888888881188181181111111 1111111111118811111111111111181111118888111111111118881111888111188881181111111 1111111111118111111881111188818111188888811111111111188881181111188818188111111 1111111111118111111111111111181111118888811111111111111111111111188818181111111 1111111111111111111111111111111111111888881111111111111111111118188881181111111 1111111111111111111111111111111111111888188111111111111111111118188818881111111 1111111111111111111111111111111111188881188111111111111111111118188111111111111 1111111111111111111111111111118188888888811111111111111111118111888811111111111 1111111111111111111111111111111111111111111111111111111111888111881111111111111 1111111111111111111111111111111111111111118188811111111118888111888811111111111 1111111111111111111111111111111111111111181818881111111188888811111111111111111 1111111111111181111118888888811811811111818888888811111188888881111111111111111 1111111111111111111111118888811111111111118888881111111888888881111111111111111 1111111111111118111111111181111111188888888888111111188888888881111111111111111 1111111111111118111111111111111111111111118811111111881188888811111111111111111 1111111111111111811111111111111111181111111111111118888118888811111111111111111 1111111111111111811181111111111111111111111111111888811188888881111111111111111 1111111111111111181111111111111111111111111111188888811888888881111111111111111 1111111111111111111818811111111111111111111111188888888888888881111111111111111 1111111111111111111188881111111111111111111111888888888888888881111111111111111 1111111111111111111118888111111111111111111118888888888888888881111111111111111 1111111111111111111118888881111111111111188888888888888888888888111111111111111 1111111111111111111118188818888888888888888888888888888888888888111118111111111 1111111111111111111888111888188888888888888888888888888111888888111111118811111 1111111111111111111111811118888888888888888888888888181811888888111111111118811 1111111111111111111111881111811111188888888888888818111111888881111111111111811 1111111111111111111111111111811111111811118188881111111111188888111111111111111 1111111111111111111111181111111111111111111111111111111111188881111111111111111 1111111111111111111111111111111111111111111111111111111111888881111111111111111 1111111111111111111111118111111111111111111111111111111111888881111111111111111 1111111111111111111111118811111111111111111111111111111118188111111111111111111 1111111111111111111118111811111111111111111111111111111181181111111111111111111 1111111111111111111111811881111111111111111111111111111811111111111111111111111 1111111111111111111111881888111111111111111111111111111118811111111111111111111
p = int(prime_str)
p > 1e100
True
p > 1e1000
False
p > 1e400
False
p > 1e300
True
p > 1e310
False