Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my answers so far #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions challenge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@

# 1. Read this file. What do you expect it to do when
# you run it?
# => Print out how many A's and Z's there are.
# 2. Now run it. Are there any bugs?
# => No bugs so far
# 3. Can you make any improvements to the program?
# => I believe I can
# 4. How many Q's are there in "prufrock.txt"?
# => There is one
# 5. (Harder) What are the 5 most common letters in "prufrock.txt"?

# When you're done (at least with 4), commit your work,
# push it to your repo, and open a pull request.

require 'pry'

text = File.read "fox.txt"
text = File.read "prufrock.txt"

cs = Hash.new
text.chars.each do |l|
Expand All @@ -27,8 +31,8 @@
end
end

ac = cs[:a]
zc = cs[:z]
ac = cs[:Q]
zc = cs[:Q]

#puts "Text is: #{text}"
puts "There are #{ac} A's and #{zc} Z's"
puts "There are #{ac} Q's and #{zc} Q's"