Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,22 @@
|
|||
insertSort = function(arr, item)
|
||||
lo = 0
|
||||
hi = arr.len
|
||||
while lo < hi
|
||||
mid = floor((lo + hi) / 2)
|
||||
ans = input("Is " + item + " less than " + arr[mid] + "? y/n: ")
|
||||
ans = ans[0].lower
|
||||
if ans == "y" then
|
||||
hi = mid
|
||||
else
|
||||
lo = mid + 1
|
||||
end if
|
||||
end while
|
||||
arr.insert(lo, item)
|
||||
end function
|
||||
|
||||
items = "violet red green indigo blue yellow orange".split
|
||||
ordered = []
|
||||
for item in items
|
||||
insertSort(ordered, item)
|
||||
end for
|
||||
print ordered
|
||||
Loading…
Add table
Add a link
Reference in a new issue