practice-problems-1/no_comments/20-num-repeats.rb
def num_repeats(string)
  count = 0
  stringHash = Hash.new

  string.chars.each do |i|
      stringHash[i] = string.count(i)
  end
  stringHash.each do |k,v|
      if v > 1
          count += 1
      end
  end
  return count
end
# Write a method that takes in a string and returns the number of
# letters that appear more than once in the string. You may assume
# the string contains only lowercase letters. Count the number of
# letters that repeat, not the number of times they repeat in the
# string.
#
# Difficulty: hard.
Write a method that takes in a string and returns the number of
letters that appear more than once in the string. You may assume
the string contains only lowercase letters. Count the number of
letters that repeat, not the number of times they repeat in the
string.

hard.
Write a method that takes in a string and returns the number of letters that appear more than once in the string . You may assume the string contains only lowercase letters . Count the number of letters that repeat not the number of times they repeat in the string . hard .
def num_repeats(string)
  count = 0
  stringHash = Hash.new
  string.chars.each do |i|
      stringHash[i] = string.count(i)
  end
  stringHash.each do |k,v|
      if v > 1
          count += 1
      end
  end
  return count
end
def num_repeats ( string ) count = 0 stringHash = Hash . new string . chars . each do | i | stringHash [ i ] = string . count ( i ) end stringHash . each do | k , v | if v > 1 count += 1 end end return count end
Write a method that takes in a string and returns the number of
letters that appear more than once in the string.
Write a method that takes in a string and returns the number of letters that appear more than once in the string .
string