<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

=begin
INPUT: Obtain a collection of numbers, a integer lower bound, and a integer upper bound

IF length of collection is 0 THEN
  return 0
IF upper bound < lower bound
  return 0
ELSE
  For each number between the upper and lower bound (including the upper and lower bound)
      create a containter that holds a empty collection
      take each number out of the collection
      compare that number with the lower bound
          IF number is less then lower bound THEN
              don't count it
          IF number is greater than upper bound THEN
              don't count it
          ELSE
            place the remaining numbers in the new collection object THEN
                 count the length of that collection object
          END IF
  END FOR
END IF

OUTPUT: Return the numbers in a collection. Should be ordered by the lower bound first and the upper bound last.

=end

# Your Solution Below

=begin

def count_between(list_of_integers, lower_bound, upper_bound)

  if list_of_integers.length == 0
      return 0
  elsif upper_bound < lower_bound
      return 0
  else
      for num in lower_bound..upper_bound
          count_integer_array = []
          list_of_integers.each do |integer|
             next if integer < lower_bound
             next if integer > upper_bound
              count_integer_array << integer
          end
      end
  end

    return count_integer_array.length

end
=end

def count_between(list_of_integers, lower_bound, upper_bound)
    if (list_of_integers.length == 0) || (upper_bound < lower_bound )
        return 0
    else
        count_integer_array = []
        list_of_integers.each do |integer|
            next if integer < lower_bound
            next if integer > upper_bound
            count_integer_array << integer
        end
    end
      return count_integer_array.length
end
<commit_msg>Refactor count_between method to use select method<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

=begin
INPUT: Obtain a collection of numbers, a integer lower bound, and a integer upper bound

IF length of collection is 0 THEN
  return 0
IF upper bound < lower bound
  return 0
ELSE
  For each number between the upper and lower bound (including the upper and lower bound)
      create a containter that holds a empty collection
      take each number out of the collection
      compare that number with the lower bound
          IF number is less then lower bound THEN
              don't count it
          IF number is greater than upper bound THEN
              don't count it
          ELSE
            place the remaining numbers in the new collection object THEN
                 count the length of that collection object
          END IF
  END FOR
END IF

OUTPUT: Return the numbers in a collection. Should be ordered by the lower bound first and the upper bound last.

=end

# Original Solution Below

=begin

def count_between(list_of_integers, lower_bound, upper_bound)

  if list_of_integers.length == 0
      return 0
  elsif upper_bound < lower_bound
      return 0
  else
      for num in lower_bound..upper_bound
          count_integer_array = []
          list_of_integers.each do |integer|
             next if integer < lower_bound
             next if integer > upper_bound
              count_integer_array << integer
          end
      end
  end

    return count_integer_array.length

end

def count_between(list_of_integers, lower_bound, upper_bound)
    if (list_of_integers.length == 0) || (upper_bound < lower_bound )
        return 0
    else
        count_integer_array = []
        list_of_integers.each do |integer|
            next if integer < lower_bound
            next if integer > upper_bound
            count_integer_array << integer
        end
    end
      return count_integer_array.length
end
=end

def count_between(list_of_integers, lower_bound, upper_bound)
  filtered_array =  list_of_integers.select { |integer| integer >= lower_bound && integer <= upper_bound }
  return filtered_array.length
end
{'fraction_non_alphanumeric': 0.0410958904109589, 'fraction_numerical': 0.005057955742887249, 'mean_word_length': 2.563063063063063, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 8, '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': '3381048', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1235, 'n_words': 564}