This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A friend of mine runs a company called Wildcard. I recently did their wildcard challenge and it was a lot of fun and a I think would be a good excercise to really stretch your Ruby skills. | |
http://www.trywildcard.com/challenge | |
Create a repo called stretch in your github. | |
Create a folder called wildcard in that repo. | |
Create folders in wildcard called problem1 and problem2. | |
You'll most likely need to use classes to do this although I know at least problem 1 can be solved without. | |
This will test your knowledge of string manipulation, objects and mainly iteration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prereqs arrays, methods, conditional logic | |
# part I. implement a maximum method that takes and array and returns the largest element of the array | |
# part II. reimplement this method as an instance method on the array class | |
def maximum(arr) | |
end | |
# now rewrite this as a method on the array class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement your own versions of collect and select | |
def my_collect(array) | |
#code goes here | |
end | |
def my_select(array) | |
# | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def my_each(array) | |
# iterates through an array | |
# some kind of loop | |
# yield access each element of the array | |
# return the origin array | |
# yield to the block with each element in the array | |
# returns the original array | |
i = 0 | |
while i < array.length | |
yield array[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance_items => true}}, | |
{"AVOCADO" => {:price => 3.00, :clearance_items => true}}, | |
{"KALE" => {:price => 3.00,:clearance_items => false}}, | |
{"KALE" => {:price => 3.00,:clearance_items => false}}, | |
{"BLACK_BEANS" => {:price => 2.50,:clearance_items => false}}, | |
{"ALMONDS" => {:price => 9.00, :clearance_items => false}}, | |
{"TEMPEH" => {:price => 3.00,:clearance_items => true}}, | |
{"CHEESE" => {:price => 6.50,:clearance_items => false}}, | |
{"BEER" => {:price => 13.00, :clearance_items => false}}, | |
{"PEANUTBUTTER" => {:price => 3.00,:clearance_items => true}}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance_items => true}}, | |
{"KALE" => {:price => 3.00,:clearance_items => false}}, | |
{"BLACK_BEANS" => {:price => 2.50,:clearance_items => false}}, | |
{"ALMONDS" => {:price => 9.00, :clearance_items => false}}, | |
{"TEMPEH" => {:price => 3.00,:clearance_items => true}}, | |
{"CHEESE" => {:price => 6.50,:clearance_items => false}}, | |
{"BEER" => {:price => 13.00, :clearance_items => false}}, | |
{"PEANUTBUTTER" => {:price => 3.00,:clearance_items => true}}, | |
{"BEETS" => {:price => 2.50,:clearance_items => false}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'debugger' | |
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance_items => true}}, | |
{"KALE" => {:price => 3.00,:clearance_items => false}}, | |
{"BLACK_BEANS" => {:price => 2.50,:clearance_items => false}}, | |
{"ALMONDS" => {:price => 9.00, :clearance_items => false}}, | |
{"TEMPEH" => {:price => 3.00,:clearance_items => true}}, | |
{"CHEESE" => {:price => 6.50,:clearance_items => false}}, | |
{"BEER" => {:price => 13.00, :clearance_items => false}}, | |
{"PEANUTBUTTER" => {:price => 3.00,:clearance_items => true}}, | |
{"BEETS" => {:price => 2.50,:clearance_items => false}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collections Practice | |
Finish the first collections assignment if you haven't already. | |
Wrap each of these problems in a method, you can also write a test for each method if you'd like to practice testing. All solutions should be generic and work for any "case" but sometimes a sample case is given. | |
These problems should get progressively more difficult. | |
Return true if every element of the tools array starts with an "r" and false otherwise. | |
tools = ["ruby", "rspec", "rails"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prereqs: iterators, hashes, conditional logic | |
# Given a hash with numeric values, return the key for the smallest value | |
def key_for_min_value(hash) | |
# code goes here | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One of the projects you can choose from this week is called the game of life | |
This is a classic problem you can do in any programming language. | |
http://en.wikipedia.org/wiki/Conway's_Game_of_Life | |
This is a good tutorial on game of life and how to use the Gosu gem to create a visualization of your game of life | |
http://www.youtube.com/watch?v=J5fesJ3wM6s | |
This is a great project to practice TDD on although it will be hard until we cover mocking and stubbing (advanced testing techniques) |