Skip to content

Commit

Permalink
Move example out of stub
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras committed Nov 9, 2024
1 parent 2174a1d commit 4ea6f33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
8 changes: 4 additions & 4 deletions exercises/practice/binary-search/.meta/example.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class BinarySearch
constructor: (@values) ->
constructor: (@array) ->

find: (value) ->
start = 0
end = @values.length - 1
end = @array.length - 1
while start <= end
mid = (start + end) // 2
item = @values[mid]
item = @array.get mid
if value == item
return mid
else if value <= item
Expand All @@ -16,4 +16,4 @@ class BinarySearch

throw new Error 'value not in array'

module.exports = BinarySearch
module.exports = BinarySearch
13 changes: 0 additions & 13 deletions exercises/practice/binary-search/binary-search.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,5 @@ class BinarySearch
constructor: (@array) ->

find: (value) ->
start = 0
end = @array.length - 1
while start <= end
mid = (start + end) // 2
item = @array.get mid
if value == item
return mid
else if value <= item
end = mid - 1
else if value >= item
start = mid + 1

throw new Error 'value not in array'

module.exports = BinarySearch

0 comments on commit 4ea6f33

Please sign in to comment.