Leaves - Cloudy#47
Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Thanks for submitting this Cloudy. Definitely some work to do here. You were on the right track with all the methods, but they're not quite working.
Suggestion: Skip all the tests but those for 1 method. Then work on that one method to the exclusion of the others until it works, then move to the next. That might help a bit.
| high = array.length - 1 | ||
| while low <= high | ||
| mid = (low + high)/2 | ||
| if (array[mid] > value_to_find |
There was a problem hiding this comment.
You haven't closed a parentheses
| if (array[mid] > value_to_find | |
| if (array[mid] > value_to_find) |
| puts "#{array[i]}" | ||
| i += 1 | ||
| end | ||
|
|
| temp = array[min_index] | ||
| array[min_index] = array[index] | ||
| array[index] = temp | ||
| else i += 1 |
There was a problem hiding this comment.
- Your indentation needs work. Maybe try using the Rufo extension to help with code formatting.
- You are missing an end
- The
.timesloop will incrementiso you don't need to do that - You should return
falseif you reach the end of the loop and don't find the item you are searching for.
| if array[i] > largest | ||
| end |
| index += 1 | ||
| if array[i] > largest | ||
| end | ||
| return largest |
There was a problem hiding this comment.
Missing an end
| return largest | |
| end | |
| return largest |
| end | ||
|
|
||
| if array[low] == value_to_find | ||
| return low |
There was a problem hiding this comment.
The method is stated above to return true if it find the element.
| return low | |
| return true |
| return low | ||
| end | ||
|
|
||
| return nil |
There was a problem hiding this comment.
The method should return true or false
| return nil | |
| return false |
| top = array[high] | ||
| bottom = array[low] | ||
| array[high] = bottom | ||
| arry[low] = top |
| smallest = array[i] | ||
| while i - 1 > length && | ||
| array[i - 1] != kaboom | ||
| index += 1 |
There was a problem hiding this comment.
You are using i instead of index in this method. Also this should be at the end of the loop.
| while i - 1 > length && | ||
| array[i - 1] != kaboom |
There was a problem hiding this comment.
Two things:
- kaboom?
- Shouldn't this just be
while i < length
No description provided.