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

Branches - Xinran and Macaria #3

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

Conversation

gracexinran
Copy link

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? First is the method signature, which is the top line; sometimes it contains parameters, and sometimes not. Then there is the method body which contains any code you want to execute in your method. Then end.
What are the advantages of using git when collaboratively working on one code base? It has the benefits of containing multiple versions of your code, and the ability to open up the file for editing by a partner. It is a fast way to share your code and changes.
What kind of relationship did you and your pair have with the unit tests? We began testing with them once we learned what they were. We tested for every feature added or edited.
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? No, we used each as we often created multiple variables within the each loop. However, we could have refactored to include an enumerable in order to create our array of indexes and to access it in our first method.
What was one method you and your pair used to debug code? We used puts plenty in order to make sure that we were outputting/returning the values we intended. We used Rake to check against provided tests.
What are two discussion points that you and your pair discussed when giving/receiving feedback from each other that you would be willing to share? It was excellent working with a partner with different strengths than me! Xinran is so good at figuring out syntax and bringing ideas to real life. Macaria is good at picking up on the main points of tasks and bringing up a lot of good ideas for our project.

@tildeee
Copy link

tildeee commented Aug 23, 2019

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions x :)
Small commits with meaningful commit messages x, I would probably prefer commit messages that are less "completes wave 2" and more "implements score_word method" or "refactors score table data structure" etc.
Code Requirements
draw_letters method x
Uses appropriate data structure to store the letter distribution x
All tests for draw_letters pass x
uses_available_letters? method x
All tests for uses_available_letters? pass x
score_word method x
Uses appropriate data structure to store the letter scores x
All tests for score_word pass x
highest_score_from method x
Appropriately handles edge cases for tie-breaking logic x
All tests for highest_score_from pass x
Overall

Great work on this project, Xinran and Macaria! Your code is smooth, logical, readable, and has overall good code style.

There are a few opportunities for refactoring on this if you had more time on this project, so I've added a few comments.

That being said, your submission is great overall! Keep up the good work!

index_of_letters.delete(index)
end
return letters_in_hand
end
Copy link

Choose a reason for hiding this comment

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

If you had more time on this project to refactor, I think that there are some built in Ruby methods that could have made your solution a little bit shorter, such as shuffle (so you could randomly shuffle letters_arr and then delete off of letters_arr, instead of relying on index_of_letters so much.)

end

# This method checks that the letters_in_hand contains the plucked letters from previous method
def uses_available_letters? (input, letters_in_hand)
Copy link

Choose a reason for hiding this comment

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

Minor nitpick: You CAN define a method with a space between the method name and the input parens, but Ruby will give a warning, because it prefers it if the method signature looks more like def uses_available_letters?(input, letters_in_hand)

input.split('').each do |tile|
if letters_in_hand_copy.include?(tile)
index_of_tile = letters_in_hand_copy.index(tile)
letters_in_hand_copy.delete_at(index_of_tile)
Copy link

Choose a reason for hiding this comment

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

Hm, in the above two lines, you find the index of tile and store it at index_of_tile, and then delete the element at that index of tile. Could we use the .delete method to delete the first occurance of tile's value? Replacing the above two lines with this line seems to work, and the tests still pass:

letters_in_hand_copy.delete(tile)

index_of_tile = letters_in_hand_copy.index(tile)
letters_in_hand_copy.delete_at(index_of_tile)
else
return false
Copy link

Choose a reason for hiding this comment

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

It's clever to return false here, because this way the method exits as soon as you need to :)

end
end
shortest_word = highest_scores.min_by { |word| word.length }
return {word: shortest_word, score: words_scores.keys.max}
Copy link

Choose a reason for hiding this comment

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

Clever!

end

# OPTIONAL METHOD: Reads from a dictionary csv to determine if input is a valid word or not. To run wave-5-game.rb must access file from adagrams directory.
def is_in_english_dict?(input)
Copy link

Choose a reason for hiding this comment

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

Fantastic work on the optional wave 5! This makes me happy!

end

# OPTIONAL METHOD: Reads from a dictionary csv to determine if input is a valid word or not. To run wave-5-game.rb must access file from adagrams directory.
def is_in_english_dict?(input)
Copy link

Choose a reason for hiding this comment

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

Also... what about the tests? :)


# OPTIONAL METHOD: Reads from a dictionary csv to determine if input is a valid word or not. To run wave-5-game.rb must access file from adagrams directory.
def is_in_english_dict?(input)
return DICTIONARY.include?([input.downcase]) ? true : false
Copy link

Choose a reason for hiding this comment

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

Nice use of a ternary! Let's keep pushing this refactor ;) Consider:

return DICTIONARY.include?([input.downcase])

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