Skip to content

Instantly share code, notes, and snippets.

@gregeng
Created October 1, 2013 12:02

Revisions

  1. gregeng created this gist Oct 1, 2013.
    62 changes: 62 additions & 0 deletions lab1-hashesandreverse.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    # A movie collection that organizes by genres
    # Recipes with ingredients
    # User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3

    ## Hashes

    movie_collection = {
    :action => ["Man on Fire", "Fight Club"]
    :adventure => ["National Treasure", "National Treasure 2"]
    :comedy => ["BASEketball", "Wedding Crashers"]
    :drama => ["Schindler's List", "Enemy at the Gates"]
    :dramedy => "Garden State"
    :horror => ["Exorcist", "The Sixth Sense"]
    }

    recipes = {
    :lasagna => ["pasta", "tomato sauce", "cheese", "ground beef"]
    :pizza => ["dough", "tomato sauce", "cheese"]
    :sushi => ["seaweed", "rice", "salmon", "cucumber", "avocado"]
    :tacos => ["corn tortillas", "pork", "cilantro", "onions"]



    }

    user_profiles = {
    :greg =>
    [
    "favorite colors" =["red","blue","green"]
    "personal_essays" =["essay_1", "essay_2", "essay_3"]
    ]
    :dave =>
    [
    "favorite colors" =["maroon","shale","lavendar"]
    "personal_essays" =["essay_1", "essay_2", "essay_3"]
    :kyle =>
    [
    "favorite colors" =["brown","neon green"]
    "personal_essays" =["essay_1", "essay_2", "essay_3"]
    ]
    }



    ####################################

    # Reverse Each Word

    def rev_sentence(sentence="this sentence is backwards")
    sentence.reverse!
    array = sentence.split(" ")
    array.reverse!
    puts array.join(" ")
    end

    rev_sentence

    ####################################