Skip to content

Commit 4f8efb2

Browse files
committed
Polymad pwned3 challenge - solve quadratics
1 parent 9803976 commit 4f8efb2

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

pwned3/polymad.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import cmath
2+
3+
coeffs = [
4+
[832, -112, 1],
5+
[888, -119, 1],
6+
[721, -110, 1],
7+
[294, -101, 1],
8+
[736, -100, 1],
9+
[812, -123, 1],
10+
[637, -98, 1],
11+
[147, -52, 1],
12+
[644, -99, 1],
13+
[882, -107, 1],
14+
[534, -95, 1],
15+
[115, -116, 1],
16+
[47, -48, 1],
17+
[774, -95, 1],
18+
[303, -104, 1],
19+
[138, -49, 1],
20+
[300, -103, 1],
21+
[855, -104, 1],
22+
[94, -95, 1],
23+
[336, -115, 1],
24+
[288, -99, 1],
25+
[495, -104, 1],
26+
[47, -48, 1],
27+
[351, -48, 1],
28+
[107, -108, 1],
29+
[364, -95, 1],
30+
[392, -57, 1],
31+
[320, -48, 1],
32+
[336, -55, 1],
33+
[552, -98, 1],
34+
[360, -49, 1],
35+
[220, -49, 1],
36+
[388, -101, 1],
37+
[329, -54, 1],
38+
[366, -125, 1],
39+
]
40+
41+
sols = []
42+
43+
for cs in coeffs:
44+
d = (cs[1]**2) - (4*cs[0]*cs[2])
45+
sol1 = (-cs[1] - cmath.sqrt(d))/(2*cs[0])
46+
sol2 = (-cs[1] + cmath.sqrt(d))/(2*cs[0])
47+
sols.append([sol1, sol2, sol1 + sol2])
48+
49+
print(sols)
50+
51+
sums = [sol[2] for sol in sols]
52+
53+
print(sums)
54+
55+
# chars = ''.join([chr(sum) for sum in sums])

0 commit comments

Comments
 (0)