<repo_name>mallorybucell/LetterWordCounter<file_sep>/README.md
# LetterWordCounter

3rd project at the IronYard. Simple letter counter- you can tell I'm still learning both ruby and to think like a programmer. I had some trouble with some of the sorting, but completed it in the end.  Also, some good teamwork on this one as far as sharing of insights and parts different classmates figured out at different times.  Yay for shared success.<file_sep>/letter-countUpdateEng.rb
require 'pry'

#Throw out punctuation (" " "." "," "'", "!", "?",)
#Ignore Case
#Print Output in order of Most Freq to Least Freq
#Works for English only

puts "Please type a string to analyze."
input = gets.chomp

puts "You typed in: #{input}"

input = input.downcase

letters = input.split("")
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#could do this simpler with just range_alpha = ("a".."z")
result = {}

letters.each do |letter|
	# see if the letter is already in result
	# if so increment count
	# if not, add it to the hash and set count to 1

	# VVVV

	# if # letter is in result
	#   # increment count for that letter by 1
	# else
	#   # add to result with count 1
	# end

	# VVVV

	# could use result.has_key? or result.include?
  when alphabet.include?(letter)
    if result[letter]
    # increment count for that letter by 1
    # result[letter] += 1
      old_count = result[letter]
      result[letter] = old_count + 1
    else
    # add to result with count 1
  	 result[letter] = 1
  	end
  end
end
#sort Hash.result by value
result = result.sort_by {|k,v| v}.reverse.to_h


puts "Result is: #{result}"

def encrypt
  #<file_sep>/letter-count-encrypt-hash.rb
˜point_values = Hash.new
point_values["a"] = "m"
point_values["b"] = "n"
point_values["c"] = "o"
point_values["d"] = "p"
point_values["e"] = "q"
point_values["f"] = "r"
point_values["g"] = "s"
point_values["h"] = "t"
point_values["i"] = "u"
point_values["j"] = "v"
point_values["k"] = "w"
point_values["l"] = "x"
point_values["m"] = "y"
point_values["n"] = "z"
point_values["o"] = "a"
point_values["p"] = "b"
point_values["q"] = "c"
point_values["r"] = "d"
point_values["s"] = "e"
point_values["t"] = "f"
point_values["u"] = "g"
point_values["v"] = "h"
point_values["w"] = "i"
point_values["x"] = "j"
point_values["y"] = "k"
point_values["z"] = "l"

puts point_values
