File size: 695 Bytes
90cd92a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import galois
import numpy as np
MOD = 7514777789

points = []

for line in open('/mnt/user/myang/LLaVA-2/my_code/encoded.txt', 'r').read().strip().split('\n'):
    x, y = line.split(' ')
    points.append((int(x), int(y)))

GF = galois.GF(MOD)
print(len(points))
matrix = []
solution = []
count = 0
for point in points:
    x, y = point
    solution.append(GF(y % MOD))
    #print("appended")
    row = []
    for i in range(3):
        row.append(GF((x ** i) % MOD))
    for i in range(3, len(points)):
        row.append(GF(0))
    
    matrix.append(GF(row))

open('/mnt/user/myang/LLaVA-2/my_code/output.bmp', 'wb').write(bytearray(np.linalg.solve(GF(matrix), GF(solution)).tolist()[:-1]))