Skip to content

Instantly share code, notes, and snippets.

@kareemgrant
Created March 26, 2015 18:07
Show Gist options
  • Save kareemgrant/a273088e9f632fe6d39c to your computer and use it in GitHub Desktop.
Save kareemgrant/a273088e9f632fe6d39c to your computer and use it in GitHub Desktop.

Homework

Goals

  1. Continue to solidify your understanding of basic Ruby programming concepts

  2. Be prepared to learn about Ruby libraries on Tuesday

Assignment

  1. Create a program to analyze a large block of text and report back on the frequency of each word in the text.
  • Start by sorting the text into a hash where each word is a key with the word's value being the amount of times it has been used in the block:
    {the: 10, john: 1, of: 15}
  • Once you've created this hash, return the word that has been used the most

  • When you're done, encapsulate your script inside of a method that can analyze any block of text fed to it

Bonus assignment: Create a "choose your own adventure" Ruby game using the gets ruby method to get user input from the command line. Have the game send the user down many different paths depending on the input that they enter. Use objects to store data about the user and different items they could collect along the way. See http://en.wikipedia.org/wiki/Interactive_fiction for a more in-depth description of "choose your own adventure"-style command line games.

Note: If you complete assignment 1 only, you are eligible for a 10/10 for homework. The bonus assignment is just a great way to get a ton more Ruby practice!

Recommended Activity

Complete as much of the "Introduction to Ruby" track on Codecademy as you can. http://www.codecademy.com/courses/ruby-beginner-en-d1Ylq?curriculum_id=5059f8619189a5000201fbcb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment