Skip to content

Instantly share code, notes, and snippets.

@davidvandusen
Forked from kvirani/README.md
Created May 5, 2015 13:36
Show Gist options
  • Save davidvandusen/aa5fabf243fe3e7cb8f7 to your computer and use it in GitHub Desktop.
Save davidvandusen/aa5fabf243fe3e7cb8f7 to your computer and use it in GitHub Desktop.

Revisions

  1. David VanDusen revised this gist May 5, 2015. 1 changed file with 0 additions and 25 deletions.
    25 changes: 0 additions & 25 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,25 +0,0 @@
    Your cofounder has left for Hawaii and asked that you take care of his puppy for 2 weeks.

    As it turns out, this dog is a menace and won’t stop barking. His name is Shakil. He exhibits the following inexplicable behavior:

    If you say anything to him, he will just bark back once ("woof"), except:
    * If you pretend to be a dog and bark ("woof") at him, he will go a bit nuts and woof back at you three times, pretty loudly: "WOOF WOOF WOOF"
    * If you explicitly use his name and tell him to stop (either "shakil stop" or "Shakil STOP!") he will not respond back with a bark (enjoy your moment of peace)
    * If you pretend to be a cat and "meow" at him, he will go berserk and woof back at you five times: "woof woof woof woof woof"
    * If you say anything else but with the word "treat" thrown into the mix, he won’t bark back, thinking he’ll be getting a treat
    * If you say "go away" he manages to actually leave you alone by leaving the room.

    We'll use a method in our ruby file to simulate the interaction with this creature.

    ### How should these behaviors map to code?

    * Starting a conversation with the silly dog implies running the program via the command line
    * Having an endless conversation with Shakil implies a loop in the program
    * Speaking to Shakil implies reading a line of user input with the gets method
    * Shakil responding to you (usually by barking) implies the program printing a line using the puts method
    * Leaving the room implies exiting the program

    ### As you are coding this, ask yourself:

    1. Are you writing a single, gigantic method or breaking down your program into logical units?
    2. Are you trying to write the entire logic for your app in one go? Instead consider writing the program in incremental steps by starting with the simplest runnable code, running it, adding slightly more code/logic, running it, and so on?
  2. @kvirani kvirani revised this gist May 4, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ We'll use a method in our ruby file to simulate the interaction with this creatu

    ### How should these behaviors map to code?

    * Starting a conversation with the stupid dog implies running the program via the command line
    * Starting a conversation with the silly dog implies running the program via the command line
    * Having an endless conversation with Shakil implies a loop in the program
    * Speaking to Shakil implies reading a line of user input with the gets method
    * Shakil responding to you (usually by barking) implies the program printing a line using the puts method
  3. @kvirani kvirani revised this gist May 4, 2014. No changes.
  4. @kvirani kvirani revised this gist May 4, 2014. 2 changed files with 28 additions and 3 deletions.
    25 changes: 25 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    Your cofounder has left for Hawaii and asked that you take care of his puppy for 2 weeks.

    As it turns out, this dog is a menace and won’t stop barking. His name is Shakil. He exhibits the following inexplicable behavior:

    If you say anything to him, he will just bark back once ("woof"), except:
    * If you pretend to be a dog and bark ("woof") at him, he will go a bit nuts and woof back at you three times, pretty loudly: "WOOF WOOF WOOF"
    * If you explicitly use his name and tell him to stop (either "shakil stop" or "Shakil STOP!") he will not respond back with a bark (enjoy your moment of peace)
    * If you pretend to be a cat and "meow" at him, he will go berserk and woof back at you five times: "woof woof woof woof woof"
    * If you say anything else but with the word "treat" thrown into the mix, he won’t bark back, thinking he’ll be getting a treat
    * If you say "go away" he manages to actually leave you alone by leaving the room.

    We'll use a method in our ruby file to simulate the interaction with this creature.

    ### How should these behaviors map to code?

    * Starting a conversation with the stupid dog implies running the program via the command line
    * Having an endless conversation with Shakil implies a loop in the program
    * Speaking to Shakil implies reading a line of user input with the gets method
    * Shakil responding to you (usually by barking) implies the program printing a line using the puts method
    * Leaving the room implies exiting the program

    ### As you are coding this, ask yourself:

    1. Are you writing a single, gigantic method or breaking down your program into logical units?
    2. Are you trying to write the entire logic for your app in one go? Instead consider writing the program in incremental steps by starting with the simplest runnable code, running it, adding slightly more code/logic, running it, and so on?
    6 changes: 3 additions & 3 deletions stupid_dog.rb → shakil_the_dog.rb
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    # Save this file to your computer so you can run it
    # via the command line (Terminal) like so:
    # $ ruby stupid_dog.rb
    # $ ruby shakil_the_dog.rb
    #
    # Your method should wait for user input, which corresponds
    # to you saying something to your dog (named Shakil).

    # You'll probably want to write other methods, but this
    # encapsulates the core dog logic
    def stupid_dog
    def shakil_the_dog
    end

    # Run our method
    stupid_dog
    shakil_the_dog
  5. @kvirani kvirani created this gist Mar 4, 2014.
    14 changes: 14 additions & 0 deletions stupid_dog.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # Save this file to your computer so you can run it
    # via the command line (Terminal) like so:
    # $ ruby stupid_dog.rb
    #
    # Your method should wait for user input, which corresponds
    # to you saying something to your dog (named Shakil).

    # You'll probably want to write other methods, but this
    # encapsulates the core dog logic
    def stupid_dog
    end

    # Run our method
    stupid_dog