-
Notifications
You must be signed in to change notification settings - Fork 29
Ports - Kasey & Sav #15
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?
Conversation
AdagramsWhat We're Looking For
|
| @@ -1,0 +1,57 @@ | |||
| def draw_letters() | |||
| pool_letters = "aaaaaaaaabbccddddeeeeeeeeeeeeffggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz".split("") | |||
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
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.
Nice data structure
| return score | ||
| end | ||
|
|
||
| def highest_score_from(words) |
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.
👍
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.