A collection of puzzles I play with and test. 👍
I have sourced these fun challenges from:
Binary Search:
def binary_search(arr, num, start, end_point)
n = arr.length
mid = (start + end_point)/2
while start <= end_point
if num == arr[mid]
return mid
end
num > mid ? start = mid + 1 : end_point = mid - 1
end
return -1
end
Recursion Recipe:
def callMyself()
if # base case
return
end
if # recursive case
return callMyself()
end
return
end