Ports - Kasey & Sav#15
Open
qqdipps wants to merge 5 commits into
Open
Conversation
AdagramsWhat We're Looking For
|
CheezItMan
reviewed
Mar 1, 2019
| @@ -0,0 +1,57 @@ | |||
| def draw_letters() | |||
| pool_letters = "aaaaaaaaabbccddddeeeeeeeeeeeeffggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz".split("") | |||
There was a problem hiding this comment.
Interesting way to structure the pool of letters.
| def draw_letters() | ||
| pool_letters = "aaaaaaaaabbccddddeeeeeeeeeeeeffggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz".split("") | ||
| hand = [] | ||
| 10.times do |
There was a problem hiding this comment.
This works well, but you can also use .sample as well.
| input.each_char do |char| | ||
| if letters_in_hand.include?(char) | ||
| letters_in_hand.each_with_index do |letter, i| | ||
| letters_in_hand.delete_at(i) if letter == char |
There was a problem hiding this comment.
Just a note, this will destructively change letters_in_hand which could cause side effects.
|
|
||
| def score_word(word) | ||
| score_chart = Hash.new(0) | ||
| score_chart = { a: 1, e: 1, i: 1, o: 1, u: 1, n: 1, r: 1, s: 1, t: 1, d: 2, g: 2, l: 1, |
| return score | ||
| end | ||
|
|
||
| def highest_score_from(words) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
deftag and method name followed by optional parameters. Then there is a code block. Finally a return statement is used to explicit return an object reference. If no return statement then the last line is implicitly returned.Enumerablemixin? If so, where and why was it helpful?.each_with_index,.each, and.each_char.