Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaves - Cloudy #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Leaves - Cloudy #47

wants to merge 2 commits into from

Conversation

OhCloud
Copy link

@OhCloud OhCloud commented Oct 18, 2019

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't closed a parentheses

Suggested change
if (array[mid] > value_to_find
if (array[mid] > value_to_find)

puts "#{array[i]}"
i += 1
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end

Suggested change
end

temp = array[min_index]
array[min_index] = array[index]
array[index] = temp
else i += 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Your indentation needs work. Maybe try using the Rufo extension to help with code formatting.
  2. You are missing an end
  3. The .times loop will increment i so you don't need to do that
  4. You should return false if you reach the end of the loop and don't find the item you are searching for.

Comment on lines +53 to +54
if array[i] > largest
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's bigger... then what?

index += 1
if array[i] > largest
end
return largest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing an end

Suggested change
return largest
end
return largest

end

if array[low] == value_to_find
return low

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is stated above to return true if it find the element.

Suggested change
return low
return true

return low
end

return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should return true or false

Suggested change
return nil
return false

top = array[high]
bottom = array[low]
array[high] = bottom
arry[low] = top

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean array?

smallest = array[i]
while i - 1 > length &&
array[i - 1] != kaboom
index += 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using i instead of index in this method. Also this should be at the end of the loop.

Comment on lines +65 to +66
while i - 1 > length &&
array[i - 1] != kaboom

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. kaboom?
  2. Shouldn't this just be while i < length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants