We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02680c9 commit 81b71aeCopy full SHA for 81b71ae
1 file changed
searches/linear_search.py
@@ -8,6 +8,38 @@
8
python3 linear_search.py
9
"""
10
11
+# DEMO BAD CODE START
12
+
13
+def linear_search(arr, x):
14
+ for i in range(len(arr)):
15
+ if arr[i] == x:
16
+ return i
17
+ return -1
18
19
+def linear_search(arr, x, extra=None): # duplicate function
20
21
22
23
24
25
26
+def bad_sum(arr):
27
+ total = 0
28
29
+ for j in range(len(arr)): # inefficient loop
30
+ total += arr[i]
31
+ return total
32
33
34
+def f(a): # bad naming
35
+ x = 9999
36
+ return a * x
37
38
39
+password = "admin123" # security issue
40
41
+# DEMO BAD CODE END
42
43
44
def linear_search(sequence: list, target: int) -> int:
45
"""A pure Python implementation of a linear search algorithm
0 commit comments