from Crypto.Util.number import bytes_to_long, long_to_bytes from itertools import permutations from SECRET import FLAG, p, q, r def inputs(): print("[DET] First things first, gimme some numbers:") M = [ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], ] try: M[0][0] = p M[0][2] = int(input("[DET] M[0][2] = ")) M[0][4] = int(input("[DET] M[0][4] = ")) M[1][1] = int(input("[DET] M[1][1] = ")) M[1][3] = int(input("[DET] M[1][3] = ")) M[2][0] = int(input("[DET] M[2][0] = ")) M[2][2] = int(input("[DET] M[2][2] = ")) M[2][4] = int(input("[DET] M[2][4] = ")) M[3][1] = q M[3][3] = r M[4][0] = int(input("[DET] M[4][0] = ")) M[4][2] = int(input("[DET] M[4][2] = ")) except: return None return M def handler(signum, frame): raise Exception("[DET] You're trying too hard, try something simpler") def fun(M): def sign(sigma): l = 0 for i in range(5): for j in range(i + 1, 5): if sigma[i] > sigma[j]: l += 1 return (-1)**l res = 0 for sigma in permutations([0,1,2,3,4]): curr = 1 for i in range(5): curr *= M[sigma[i]][i] res += sign(sigma) * curr return res def main(): print("[DET] Welcome") M = inputs() if M is None: print("[DET] You tried something weird...") return res = fun(M) print(f"[DET] Have fun: {res}") if __name__ == "__main__": main()