Skip to content

Instantly share code, notes, and snippets.

View blake41's full-sized avatar

Blake Johnson blake41

  • http://blakejohnson.brandyourself.com/
View GitHub Profile
@blake41
blake41 / wilcard challenge.txt
Last active December 28, 2015 19:39
Solve the wildcard challenge
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.
# 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
Implement your own versions of collect and select
def my_collect(array)
#code goes here
end
def my_select(array)
#
end
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]
@blake41
blake41 / update counts.rb
Created November 21, 2013 15:52
green grocer review
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}},
@blake41
blake41 / green_grocer.rb
Created November 22, 2013 15:44
nikkis solution we're reviewing in class
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}}]
@blake41
blake41 / green grocer.rb
Created November 22, 2013 17:00
second time we built the green grocer
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}}]
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"]
# 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
@blake41
blake41 / game of life.txt
Last active December 30, 2015 01:18
Game of life
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)