Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# probe: sorting a List[Int] in place with nested loops and a swap
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: [1, 2, 5, 5, 6, 9]
|
||||
# expect-stdout: 0
|
||||
def bubble_sort(mut xs: List[Int]):
|
||||
var n = len(xs)
|
||||
for i in range(n):
|
||||
for j in range(n - 1 - i):
|
||||
if xs[j] > xs[j + 1]:
|
||||
var tmp = xs[j]
|
||||
xs[j] = xs[j + 1]
|
||||
xs[j + 1] = tmp
|
||||
|
||||
|
||||
def main():
|
||||
var xs: List[Int] = [5, 2, 9, 1, 5, 6]
|
||||
bubble_sort(xs)
|
||||
print(xs)
|
||||
var empty = List[Int]()
|
||||
bubble_sort(empty)
|
||||
print(len(empty))
|
||||
Reference in new issue
Block a user