Skip to content

Leaves - Cloudy#47

Open
OhCloud wants to merge 2 commits into
Ada-C12:masterfrom
OhCloud:master
Open

Leaves - Cloudy#47
OhCloud wants to merge 2 commits into
Ada-C12:masterfrom
OhCloud:master

Conversation

@OhCloud

@OhCloud OhCloud commented Oct 18, 2019

Copy link
Copy Markdown

No description provided.

@CheezItMan CheezItMan left a comment

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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