Skip to content

Margaret #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Margaret #4

wants to merge 1 commit into from

Conversation

msfinnan
Copy link

Hi Chris, I'm trying to do with with the color method and BFS but it's not working. Can you take a look and leave some comments? Thanks

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.

Hey Margaret,

This is almost perfect, but for one small error in a place neither of us looked at closely. It took me over an hour to figure it out. As usual it's in the last place you'd look. Take a look at my suggestion and see if you agree.

You have to do something with the return value of bfs.

q = []
cur = index
q << cur

Choose a reason for hiding this comment

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

I would add the starting point of this BFS' color to compat and then use compat[elem] throughout instead of static colors.

end
compat = {}
dislikes.each_with_index do |neighbors, index|
bfs(dislikes, compat, index)

Choose a reason for hiding this comment

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

You are actually not doing anything with the return value for bfs. So... maybe:

Suggested change
bfs(dislikes, compat, index)
unless bfs(dislikes, compat, index)
return false
end

q << elem
end
end
end

Choose a reason for hiding this comment

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

Suggested change
end
end
return true

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