Skip to content

Commit

Permalink
#66 change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtask committed May 15, 2024
1 parent d359ea5 commit e907391
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/solutions/chapter5/problem2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e907391

Please sign in to comment.