Skip to content

Commit

Permalink
Might as well use array size directly
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryb committed Jul 15, 2009
1 parent d5ab509 commit 33e4d64
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions 1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ def phrases(number)

def double_words(strings)
all_strings = []
num_words = strings.size

# Extracting double-word phrases
(0...num_words - 1).each do |i|
(0...strings.size - 1).each do |i|
all_strings << "#{strings[i]} #{strings[i + 1]}"
end
return all_strings
end

def triple_words(strings)
all_strings = []
num_words = strings.size

(0...num_words - 2).each do |i|
(0...strings.size - 2).each do |i|
all_strings << "#{strings[i]} #{strings[i + 1]} #{strings[i + 2]}"
end
return all_strings
Expand Down

0 comments on commit 33e4d64

Please sign in to comment.