<commit_before># Count Between

# I worked on this challenge by myself.

# count_between is a method with three arguments:
#   1. An array of integers
#   2. An integer lower bound
#   3. An integer upper bound
#
# It returns the number of integers in the array between the lower and upper bounds,
# including (potentially) those bounds.
#
# If +array+ is empty the method should return 0

# Your Solution Below
# Pseudocode
# def count_between(list_of_integers, lower_bound, upper_bound)
#   # Create an array with zero elements.
#   array=Array.new(0)
#   # Take each element of the list_of_integers array and compare with lower_bound.
#   list_of_integers.each do |integer|
#     #If it is larger or equals to the lower_bound, then
#     # Check if it is smaller or equals to the upper_bound.
#       if (integer > lower_bound) || (integer == lower_bound)
#           if (integer < upper_bound) || (integer == upper_bound)
#           #If it is, take this element and push into the new array.
#               array.push(integer)
#           end
#       end
#   # Take next following element to compare both lower bound and upper_bound.
#   # Continue this until list_of_integers array is empty.
#   end
#   # Once it is empty, return the length of newly created array.
#   return array.length
# end
# # puts count_between([13,41,6,90],2,45)
# # array = [13,41,6]
# # array.length = 3
# #Refactored Solution

def count_between(list_of_integers, lower_bound, upper_bound)
    (lower_bound..upper_bound).bsearch { |i| list_of_integers[i] }
end
<commit_msg>Work on the refactoring solution<commit_after># Count Between

# I worked on this challenge by myself.

# count_between is a method with three arguments:
#   1. An array of integers
#   2. An integer lower bound
#   3. An integer upper bound
#
# It returns the number of integers in the array between the lower and upper bounds,
# including (potentially) those bounds.
#
# If +array+ is empty the method should return 0

# Your Solution Below
# Pseudocode
# def count_between(list_of_integers, lower_bound, upper_bound)
#   # Create an array with zero elements.
#   array=Array.new(0)
#   # Take each element of the list_of_integers array and compare with lower_bound.
#   list_of_integers.each do |integer|
#     #If it is larger or equals to the lower_bound, then
#     # Check if it is smaller or equals to the upper_bound.
#       if (integer > lower_bound) || (integer == lower_bound)
#           if (integer < upper_bound) || (integer == upper_bound)
#           #If it is, take this element and push into the new array.
#               array.push(integer)
#           end
#       end
#   # Take next following element to compare both lower bound and upper_bound.
#   # Continue this until list_of_integers array is empty.
#   end
#   # Once it is empty, return the length of newly created array.
#   return array.length
# end
# # puts count_between([13,41,6,90],2,45)
# # array = [13,41,6]
# # array.length = 3
# #Refactored Solution

def count_between(list_of_integers, lower_bound, upper_bound)
    # (lower_bound..upper_bound).bsearch { |i| list_of_integers[i] }
    list_of_integers.count { |integer| lower_bound < integer < upper_bound }
end

{'fraction_non_alphanumeric': 0.08722741433021806, 'fraction_numerical': 0.013084112149532711, 'mean_word_length': 3.422865013774105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6701715', 'n_tokens_mistral': 1002, 'n_tokens_neox': 975, 'n_words': 375}