Created
March 7, 2013 08:15
-
-
Save jkaihsu/5106394 to your computer and use it in GitHub Desktop.
Write a method count_between which takes three arguments as input:
An Array of integers
An integer lower bound
An integer upper bound
count_between should return the number of integers in the Array between the two bounds, including the bounds It should return 0 if the Array is empty.
This file contains 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
def count_between(array, lower_bound, upper_bound) | |
array.count{|x| x >= lower_bound && x <= upper_bound} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment