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

map and select done! :) #30

Open
wants to merge 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,68 @@ def test_count_numbers_greater_than_17
numbers = [9, 18, 12, 17, 1, 3, 99]
tally = 0
numbers.each do |number|
# Your code goes here
tally += 1 if number > 17
end
assert_equal 2, tally
end

def test_count_words_that_are_uppercase
skip

words = ["trousers", "SOCKS", "sweater", "Cap", "SHOE", "TIE"]
tally = 0
# Your code goes here
words.each do |word|
tally += 1 if word.upcase == word
end
assert_equal 3, tally
end

def test_count_words_ending_in_ing
skip

words = ["thought", "brake", "shin", "juice", "trash"]
# Your code goes here
tally = 0
words.each do |word|
tally +=1 if word.end_with?('ing')
end
assert_equal 0, tally
end

def test_count_even_numbers
skip

numbers = [9, 2, 1, 3, 18, 39, 71, 4, 6]
# Your code goes here
tally = 0
numbers.each do |number|
tally +=1 if number.even?
end
assert_equal 4, tally
end

def test_count_multiples_of_5
skip

numbers = [2, 5, 19, 25, 35, 67]
# Your code goes here
tally = 0
numbers.each do |number|
tally +=1 if number % 5 == 0
end
assert_equal 3, tally
end

def test_count_round_prices
skip

prices = [1.0, 3.9, 5.99, 18.5, 20.0]
# Your code goes here
tally = 0
prices.each do |price|
tally +=1 if (price - price.floor) == 0
end
assert_equal 2, tally
end

def test_count_four_letter_words
skip

words = ["bake", "bark", "corn", "apple", "wart", "bird", "umbrella", "fart"]
# Your code goes here
tally = 0
words.each do |word|
tally +=1 if word.length == 4
end
assert_equal 6, tally
end

Expand Down
38 changes: 25 additions & 13 deletions exercises/count_test.rb → exercises/test/count_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,62 @@ def test_count_count_words_with_e
def test_count_numbers_greater_than_17
numbers = [9, 18, 12, 17, 1, 3, 99]
tally = numbers.count do |number|
# Your code goes here
number > 17
end
assert_equal 2, tally
end

def test_count_words_that_are_uppercase
skip

words = ["trousers", "SOCKS", "sweater", "Cap", "SHOE", "TIE"]
# Your code goes here
tally = words.count do |word|
word.upcase == word
end
assert_equal 3, tally
end

def test_count_words_ending_in_ing
skip

words = ["thought", "brake", "shin", "juice", "trash"]
# Your code goes here
tally = words.count do |word|
word.end_with?('ing')
end
assert_equal 0, tally
end

def test_count_even_numbers
skip

numbers = [9, 2, 1, 3, 18, 39, 71, 4, 6]
# Your code goes here
tally = numbers.count do |number|
number.even?
end
assert_equal 4, tally
end

def test_count_multiples_of_5
skip

numbers = [2, 5, 19, 25, 35, 67]
# Your code goes here
tally = numbers.count do |number|
number % 5 == 0
end
assert_equal 3, tally
end

def test_count_round_prices
skip

prices = [1.0, 3.9, 5.99, 18.5, 20.0]
# Your code goes here
tally = prices.count do |price|
price - price.floor == 0
end
assert_equal 2, tally
end

def test_count_four_letter_words
skip

words = ["bake", "bark", "corn", "apple", "wart", "bird", "umbrella", "fart"]
# Your code goes here
tally = words.count do |word|
word.length == 4
end
assert_equal 6, tally
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,115 @@ def test_no_waldo
words = ["scarf", "sandcastle", "flag", "pretzel", "crow", "key"]
found = nil
words.each do |word|
# Your code goes here
if word == 'waldo'
found = 'waldo'
break
end
end
assert_equal nil, found
end

def test_find_waldo
skip

words = ["noise", "dog", "fair", "house", "waldo", "bucket", "fish"]
found = nil
# Your code goes here
words.each do |word|
if word == 'waldo'
found = 'waldo'
break
end
end
assert_equal "waldo", found
end

def test_cannot_find_3_letter_words
skip

words = ["piglet", "porridge", "bear", "blueberry"]
# Your code goes here
found = nil
words.each do |word|
if word.length == 3
found = word
break
end
end
assert_equal nil, found
end

def test_find_13
skip

numbers = [2, 13, 19, 8, 3, 27]
# Your code goes here
found = nil
numbers.each do |number|
if number == 13
found = 13
break
end
end
assert_equal 13, found
end

def test_find_first_even_number
skip

numbers = [3, 7, 13, 11, 10, 2, 17]
# Your code goes here
found = nil
numbers.each do |number|
if number.even?
found = number
break
end
end
assert_equal 10, found
end

def test_find_first_multiple_of_3
skip

numbers = [2, 8, 9, 27, 24, 5]
# Your code goes here
found = nil
numbers.each do |number|
if number % 3 == 0
found = number
break
end
end
assert_equal 9, found
end

def test_find_first_word_starting_with_q
skip

words = ["weirdo", "quill", "fast", "quaint", "quitter", "koala"]
# Your code goes here
found = nil
words.each do |word|
if word.start_with? 'q'
found = word
break
end
end
assert_equal "quill", found
end

def test_find_first_word_ending_with_er
skip

words = ["biggest", "pour", "blight", "finger", "pie", "border"]
# Your code goes here
found = nil
words.each do |word|
if word.end_with? 'er'
found = word
break
end
end
assert_equal "finger", found
end

def test_find_first_number_greater_than_20
skip

numbers = [1, 8, 19, 21, 29, 31, 34]
# Your code goes here
found = nil
numbers.each do |number|
if number > 20
found = number
break
end
end
assert_equal 21, found
end

Expand Down
49 changes: 32 additions & 17 deletions exercises/find_test.rb → exercises/test/find_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,79 @@ def test_find_first_seven_letter_word
def test_no_waldo
words = ["scarf", "sandcastle", "flag", "pretzel", "crow", "key"]
found = words.find do |word|
# Your code goes here
word == 'waldo'
end
assert_equal nil, found
end

def test_find_waldo
skip
words = ["noise", "dog", "fair", "house", "waldo", "bucket", "fish"]
# Your code goes here
found = words.find do |word|
word == 'waldo'
end
assert_equal "waldo", found
end

def test_cannot_find_3_letter_words
skip

words = ["piglet", "porridge", "bear", "blueberry"]
# Your code goes here
found = words.find do |word|
word.length == 3
end
assert_equal nil, found
end

def test_find_13
skip

numbers = [2, 13, 19, 8, 3, 27]
# Your code goes here
found = numbers.find do |number|
number == 13
end
assert_equal 13, found
end

def test_find_first_even_number
skip

numbers = [3, 7, 13, 11, 10, 2, 17]
# Your code goes here
found = numbers.find do |number|
number.even?
end
assert_equal 10, found
end

def test_find_first_multiple_of_3
skip

numbers = [2, 8, 9, 27, 24, 5]
# Your code goes here
found = numbers.find do |number|
number % 3 == 0
end
assert_equal 9, found
end

def test_find_first_word_starting_with_q
skip

words = ["weirdo", "quill", "fast", "quaint", "quitter", "koala"]
# Your code goes here
found = words.find do |word|
word.start_with? 'q'
end
assert_equal "quill", found
end

def test_find_first_word_ending_with_er
skip

words = ["biggest", "pour", "blight", "finger", "pie", "border"]
# Your code goes here
found = words.find do |word|
word.end_with? 'er'
end
assert_equal "finger", found
end

def test_find_first_number_greater_than_20
skip

numbers = [1, 8, 19, 21, 29, 31, 34]
# Your code goes here
found = numbers.find do |number|
number > 20
end
assert_equal 21, found
end

Expand Down
Loading