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

Edges Layla and Dionisia's Adagrams! #16

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

Conversation

larachan15
Copy link

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? The two components are method signature and parameters.
What are the advantages of using git when collaboratively working on one code base? Contributors are able to work on one project simultaneously and have access to the most recent changes.
What kind of relationship did you and your pair have with the unit tests? We each took turns being the driver and navigator.
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? We didn't use any methods from the 'Enumberable' mixin because it didn't make sense with our approach.
What was one method you and your pair used to debug code? We used pry and running rake to check for bugs.
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? We were both really good about creating a plan of action first before attempting to code anything. We also discussed our personal strengths and weaknesses when it comes to programing, analyzing and understanding the requirements.

@droberts-sea
Copy link

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions yes - I would like to see you go into a little more depth on these
Both teammates contributed to the codebase yes
Small commits with meaningful commit messages yes
Code Requirements
draw_letters method
Uses appropriate data structure to store the letter distribution see inline
All tests for draw_letters pass yes
uses_available_letters? method
All tests for uses_available_letters? pass yes, but there are a couple of bugs here - see comments inline
score_word method
Uses appropriate data structure to store the letter scores yes
All tests for score_word pass yes
highest_score_from method
Appropriately handles edge cases for tie-breaking logic yes
All tests for highest_score_from pass yes
Overall

Good work overall. You've done a good job of writing clean, readable code that solves the problem at hand. There are a couple of bugs with your uses_available_letters? method, which I've called out below, and a few places where you code could be cleaned up or structured differently, but in general I'm pretty happy with this submission. Keep up the hard work!

def game_instructions
puts "Based on these letters, give us a word."
print "Word: "
end

Choose a reason for hiding this comment

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

You shouldn't need to implement these methods - that's what the wave-X-game.rb files attached to this project are for.

# wave 1
def stores_letters
letters = [ "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "C", "C", "D", "D", "D", "D", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "F", "F", "G", "G", "G", "H", "H", "I", "I", "I", "I", "I", "I", "I", "I", "I", "J", "K", "L", "L", "L", "L", "M", "M", "N", "N", "N", "N", "N", "N", "O", "O", "O", "O", "O", "O", "O", "O", "P", "P", "Q", "R", "R", "R", "R", "R", "R", "S", "S", "S", "S", "T", "T", "T", "T", "T", "T", "U", "U", "U", "U", "V", "V", "W", "W", "X", "Y", "Y", "Z" ]
end

Choose a reason for hiding this comment

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

This data structure makes sense for storing the pool of letters. However, laid out like this it's not easy to see the distribution of letters. Something like this might be a bit easier to read:

letters = [
  "A", "A", "A", "A", "A", "A", "A", "A", "A",
  "B", "B",
  "C", "C",
  ...
]

Or, if you were feeling fancy:

letter_distribution = {
  A: 9,
  B: 2,
  C: 2,
  ...
}
letters = []
letter_distribution.each do |letter, count|
  count.times do
    letters << letter
  end
end

def uses_available_letters?(input, letters_in_hand)
input = input.upcase.split("")
input.each do |letter|
if letters_in_hand.include?(letter)

Choose a reason for hiding this comment

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

There are two problems with this implementation:

  1. You will never return true for a word with a repeated letter. For example,

    hand = ["E", "F", "R", "A", "E", "L", "V", "A", "D", "K"]
    uses_available_letters?("ADA", hand)
    # => false

    The reason why is that Ruby's Array#delete method will remove all matching elements from an array, not just the first match.

  2. This method is destructive! Because you call delete on the input, the hand will be reduced by the letters in the input. For example:

    hand = draw_letters
    puts hand
    # => ["T", "T", "E", "F", "R", "A", "E", "L", "V", "A"]
    uses_available_letters?('tte', hand)
    puts hand
    # => ["E", "F", "R", "A", "E", "L", "V", "A"]

    This is bad because it's unexpected behavior. Nothing about "check whether this word is made up of letters in this hand" suggests that the hand will be changed in the process, but that's exactly what happens.

    The way to address this problem would be to make a copy of the hand before removing letters from it.

I will acknowledge that none of the tests checked for either of these behaviors, but that doesn't change the fact that they're bugs.

score_hash = {
"A" => 1,
"E" => 1,
"I" => 1,

Choose a reason for hiding this comment

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

I like this data structure. Why not store this data in a constant?

# if current word has 10 letters and current winner does not,
# current word becomes new current winner.
if word.length == 10 && winning_word_and_score[:word].length != 10
winning_word_and_score[:word] = word

Choose a reason for hiding this comment

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

Good work getting this tricky tie-breaking logic sorted out.

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.

3 participants