From 2513c935dda6ff1a65c62c2993b1cd5c34b4cd2c Mon Sep 17 00:00:00 2001 From: mbeisel Date: Thu, 21 Mar 2024 13:02:26 +0100 Subject: [PATCH] reformating --- app/helperfunctions.py | 4 ++-- app/services/objective_service.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helperfunctions.py b/app/helperfunctions.py index 0b9b2fc..a6edeec 100644 --- a/app/helperfunctions.py +++ b/app/helperfunctions.py @@ -53,12 +53,12 @@ def find_period(result_list: [(int, int, int)], n: int, p: int, g: int) -> int: p + 1 ) # init to p+1 (sth larger than the real result) for (y1, _, _) in result_list: - meas_div = y1 / (2**n) + meas_div = y1 / (2 ** n) frac_meas = Fraction(meas_div).limit_denominator(p - 1) # check if denominator fits r_candidate = frac_meas.denominator - if g**r_candidate % p == 1: + if g ** r_candidate % p == 1: # fits if r_candidate < smallest_fitting_denominator: smallest_fitting_denominator = r_candidate diff --git a/app/services/objective_service.py b/app/services/objective_service.py index 1fc8431..6086989 100644 --- a/app/services/objective_service.py +++ b/app/services/objective_service.py @@ -120,13 +120,13 @@ def generate_shor_discrete_log_objective_response( r = find_period(res, n, input.p, input.g) # k is inferred from the measurement result from first stage - k = int(round((y1 * r) / (2**n), 0)) + k = int(round((y1 * r) / (2 ** n), 0)) print("k = ", k) # m (the discrete log) is calculated by using the congruence: # ((km mod r)/r)*2^n = m_stage2 # v = m_stage2*r/2^n - v = (y2 * r) / (2**n) + v = (y2 * r) / (2 ** n) # print("v=", v) # = km mod r # k inverse exists? @@ -137,7 +137,7 @@ def generate_shor_discrete_log_objective_response( # print("found m=", m) # check if this m actually fits - if (input.g**m % input.p) == input.b: + if (input.g ** m % input.p) == input.b: correct_m = m graphic = None