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

Sandy & Madeline #28

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .floo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "https://floobits.com/spv1/adagrams"
}
6 changes: 6 additions & 0 deletions .flooignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extern
node_modules
tmp
vendor
.idea/workspace.xml
.idea/misc.xml
121 changes: 121 additions & 0 deletions lib/adagrams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# wave 1
def draw_letters
Comment on lines +1 to +2
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Straightforward, and effective

letters_array = [
"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"
]

letters = letters_array.shuffle.pop(10)

return letters
end

# wave 2
puts "Enter in a word: "
input = gets.chomp.to_s

letters_in_hand = input.split(//)
print letters_in_hand
Comment on lines +38 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
puts "Enter in a word: "
input = gets.chomp.to_s
letters_in_hand = input.split(//)
print letters_in_hand


def uses_available_letters?(input, letters_in_hand)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

check_input = input.split(//)

my_letters_in_hand = Array.new(letters_in_hand)

check_input.each do |letter|
letter_index = my_letters_in_hand.find_index(letter)

if letter_index == nil
return false
end

my_letters_in_hand.delete_at(letter_index)
end

return true
end

# wave 3
def score_word(word)
Comment on lines +62 to +63
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

# check_input = word.split(//)
# print check_input
score = 0
word.split(//).each do |letter|
case letter.upcase
when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T"
score += 1
when "D", "G"
score += 2
when "B", "C", "M", "P"
score += 3
when "F", "H", "V", "W", "Y"
score += 4
when "K"
score += 5
when "J", "X"
score += 8
when "Q", "Z"
score += 10
end
end

if word.length >= 7 && word.length <= 10
score += 8
end

return score
end

# wave 4
def highest_score_from(words)
Comment on lines +93 to +94
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Well done!

highest_score = 0
highest_score_length = 0
highest_word = nil

words.each do |word|
score = score_word(word)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
score = score_word(word)
score = score_word(word)


if highest_score < score
highest_score = score
highest_word = word
highest_score_length = word.length
elsif highest_score == score && highest_score_length != 10
if word.length == 10
highest_score_length = word.length
highest_word = word
elsif word.length < highest_word.length
highest_score_length = word
highest_word = word
end
end
end

highest_score_hash = {
:word => highest_word,
:score => highest_score
}
end