Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Binary-search/Ring/binary-search.ring
Normal file
20
Task/Binary-search/Ring/binary-search.ring
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
decimals(0)
|
||||
array = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
|
||||
|
||||
find= 42
|
||||
index = where(array, find, 0, len(array))
|
||||
if index >= 0
|
||||
see "the value " + find+ " was found at index " + index
|
||||
else
|
||||
see "the value " + find + " was not found"
|
||||
ok
|
||||
|
||||
func where a, s, b, t
|
||||
h = 2
|
||||
while h<(t-b) h *= 2 end
|
||||
h /= 2
|
||||
while h != 0
|
||||
if (b+h)<=t if s>=a[b+h] b += h ok ok
|
||||
h /= 2
|
||||
end
|
||||
if s=a[b] return b-1 else return -1 ok
|
||||
Loading…
Add table
Add a link
Reference in a new issue