-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: master
Are you sure you want to change the base?
Margaret #4
Conversation
There was a problem hiding this 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 | ||
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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:
bfs(dislikes, compat, index) | |
unless bfs(dislikes, compat, index) | |
return false | |
end |
q << elem | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | |
end | |
return true |
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