From e907391b07ff1e608f7b12e1a85ef2843e3d87be Mon Sep 17 00:00:00 2001 From: Krzysztof Wojtas Date: Wed, 15 May 2024 23:40:13 +0200 Subject: [PATCH] #66 change variable names --- src/solutions/chapter5/problem2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/solutions/chapter5/problem2.py b/src/solutions/chapter5/problem2.py index c56bb4c..8a01930 100644 --- a/src/solutions/chapter5/problem2.py +++ b/src/solutions/chapter5/problem2.py @@ -19,15 +19,15 @@ def random_search(A: Array, n: int, x: int) -> Optional[int]: Returns: An index i such that x equals A[i] or None if x does not appear in A. """ - B = Array(1, n) - for k in range_of(1, to=n): - B[k] = False - checked = 0 - while checked < n: + picked = Array(1, n) + for i in range_of(1, to=n): + picked[i] = False + k = 0 + while k < n: i = random(1, n) if A[i] == x: return i - if not B[i]: - B[i] = True - checked += 1 + if not picked[i]: + picked[i] = True + k += 1 return None