Hack The Box / Challenges / Crypto / Infinite Descent

I used the following code to solve this challenge:

n = 609277358770565591308030699196218597298172238160914688704687281505
3510234508554419500114217949774730075697611835999153176610412137900414
6329976732080428122272205922112100073487631152244297343150154109815442
6813203111221347319912822819691524929330558823773040918446166711598963
54284349735375653609635116671867

print "Trying to factor n..."
print "n=",n

for a in xrange(-10,10,1):

    f, r = exact_sqrt(a*a+4*n)
    p1 = (a + f)/2

    if r != 0:
        print "  sqrt is not from perfect integer, trying other a..."
        continue

    print "\n  Found perfect sqrt integer using a=",a
    print "  f= %d\n  r= %0.f" % (f, r)
    if p1 > 0 and r == 0:
        p = p1
        q = p1 - a
        print "  found p= %d" % p
        print "  found q= %d" % q
        break

# Take pre-load and use it in twister as seeds
seedval = str(500491164140527509149577108534901274218266116126419727365281831678182316)

# According to comments, we need to feed 3 digit seeds
seeds = [seedval[i:i+3] for i in range(0, len(seedval), 3)]
for seed in seeds:
    list = gen_and_check(int(seed))
    print("%c" % list)
jemos / Dec, 4 2018