Skip to content

Kay and Laura.rb#21

Open
lauracodecreations wants to merge 17 commits into
Ada-C10:masterfrom
lauracodecreations:master
Open

Kay and Laura.rb#21
lauracodecreations wants to merge 17 commits into
Ada-C10:masterfrom
lauracodecreations:master

Conversation

@lauracodecreations
Copy link
Copy Markdown

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? method signature, body block, parameters
What are the advantages of using git when collaboratively working on one code base? you make sure you are both working on the most updated version of the file.
What kind of relationship did you and your pair have with the unit tests? we learned how to debug them, create them, and how to use pry with it, and their syntax
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? yes, it helped us to more efficiently iterate through the data structure. We used max_by to select max score and .sort_by to sort the strings by length and select, to select the key that matched the value
What was one method you and your pair used to debug code? pry, and irb
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? how we improved our communication as the days passed, and how we became more efficient presenting and emerging ideas especially using the white board

@CheezItMan
Copy link
Copy Markdown

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions Check
Both teammates contributed to the codebase I assume so
Small commits with meaningful commit messages Small commits, for your messages I suggest you avoid mentioning waves and talk about the functionality added.
Code Requirements
draw_letters method Check, but it's a bit awkward. I left some notes in the codebase.
Uses appropriate data structure to store the letter distribution Well done!
All tests for draw_letters pass Check
uses_available_letters? method Check, but you have some redundant code here. I left notes in the code.
All tests for uses_available_letters? pass Check
score_word method Check
Uses appropriate data structure to store the letter scores Nice!
All tests for score_word pass Check
highest_score_from method Yes, but you have some inefficiencies here. You loop through the tied words and each time the loop goes, it sorts the list again.
Appropriately handles edge cases for tie-breaking logic It works.
All tests for highest_score_from pass Check
Overall Overall you did ok, you had some inefficiencies and need to refactor your code.

Comment thread Kay_and_Laura_adagrams.rb
def draw_letters

# all letters
letters = %W(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 )
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good data structure to use!

Comment thread Kay_and_Laura_adagrams.rb
10.times do
# check if index is in indices_used array , if true generate new random index
while indices_used.include?(index)
index = Random.rand(min..max)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a note, this loop could potentially go a long time. You would do better to remove an element once you've selected it.

Comment thread lib/adagrams.rb
result << true
else
# user used a letter that does not exists
result << false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you should just return false.

Comment thread lib/adagrams.rb
input.each_char do |letter|
# check if letter exists in letters_in_han
if letters_in_hand.include?(letter)
result << true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What if a letter appears twice in input, but not in letters_in_hand

Comment thread lib/adagrams.rb
end
final_results << result.all? { |value| value == true}

input.each_char do |letter|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be doing what the above did, but better. Avoid duplication of effort.

Comment thread lib/adagrams.rb
group4 = %w(F H V W Y)
group5 = %w(J X)
group6 = %w(Q Z)
word.upcase.each_char do |letter|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/adagrams.rb
score = data.select{ |k, v| k == winner}.values[0]
return {:word => winner, :score => score}
else # select shortest word and return it as a winner
winner = ties_words.sort_by {|x| x.length}.first
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 have a loop and inside that you're sorting each iteration. This is a bit inefficient.

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