Skip to content

Instantly share code, notes, and snippets.

@tooky
Last active December 23, 2015 21:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tooky/6696165 to your computer and use it in GitHub Desktop.
Save tooky/6696165 to your computer and use it in GitHub Desktop.
On The Beach Academy - Homework

Week 1 Homework

  • Complete the ruby koans
  • Use RSpec to test-drive a solution to either:
  • Write a 10 minute presentation about the topic card you pick
  • BONUS: clone Corey Haines' [practice repo] 1, and use it to help you complete a Game of Life solution.
    • You will need to research [cucumber] 2 and [bundler] 3
    • Use cucumber and rspec to help guide your code
    • Look out for when things feel more appropriate to test with rspec or with cucumber

Notes

  • Please document your working using [good commit messages] 4
  • Publish all code on your github account, and let me know where it is. Simplest might be to add me as a collaborator, or tag me in a commit message or pull request (@tooky)
  • Please ask me questions steve (at) heavi.es / @tooky

Week 2 Homework

  • Finish any home work from last week that you didn't get to - including practice-game-of-life!
  • Write up a blog post explaining Ruby Method Despatch, reference include, extend and super.
    • BONUS: Newer versions of ruby also have prepend
  • Read [Think Like (a) Git] git and write a blog post about the thing you found most interesting, or something that suprised you.
  • Use RSpec to test-drive a solution to the other kata from last week:
  • Review another academy member's kata from last week using github. Try to make constructive comments about how they could improve the design of their code.

Notes

  • If you don't have a blog, either publish it as a gist gist, or try wordpress or tumblr
  • Please document your working using [good commit messages] tpope
  • Publish all code on your github account, and let me know where it is. Simplest might be to add me as a collaborator, or tag me in a commit message or pull request (@tooky)
  • Please ask me questions steve (at) heavi.es / @tooky
  • Share your blog posts with the team!

Week 3 Homework

  • Publish the blog posts from last week - add the urls as a comment on this gist, please!
  • Review the other pull requests and one constructive comment to each pull request
  • Try adding a the following features to bookshelf:
    • Show a count of books on the home page
    • Allow people to add new books through the UI
    • When I search for "ruby" I want to find "Ruby Programming" even through I used a lower case 'r'

Create a program, which, given a valid sequence of rolls for one line of American Ten-Pin Bowling, produces the total score for the game. Here are some things that the program will not do:

  • We will not check for valid rolls.
  • We will not check for correct number of rolls and frames.
  • We will not provide scores for intermediate frames.
  • Depending on the application, this might or might not be a valid way to define a complete story, but we do it here for purposes of keeping the kata light. I think you'll see that improvements like those above would go in readily if they were needed for real.

We can briefly summarize the scoring for this form of bowling:

  • Each game, or "line" of bowling, includes ten turns, or "frames" for the bowler.
  • In each frame, the bowler gets up to two tries to knock down all the pins.
  • If in two tries, he fails to knock them all down, his score for that frame is the total number of pins knocked down in his two tries.
  • If in two tries he knocks them all down, this is called a "spare" and his score for the frame is ten plus the number of pins knocked down on his next throw (in his next turn).
  • If on his first try in the frame he knocks down all the pins, this is called a "strike". His turn is over, and his score for the frame is ten plus the simple total of the pins knocked down in his next two rolls.
  • If he gets a spare or strike in the last (tenth) frame, the bowler gets to throw one or two more bonus balls, respectively. These bonus throws are taken as part of the same turn. If the bonus throws knock down all the pins, the process does not repeat: the bonus throws are only used to calculate the score of the final frame.
  • The game score is the total of all frame scores.

More info on the rules at: www.topendsports.com/sport/tenpin/scoring.htm

Harry Potter Kata

To try and encourage more sales of the 5 different Harry Potter books they sell, a bookshop has decided to offer discounts of multiple-book purchases.

One copy of any of the five books costs 8 EUR.

If, however, you buy two different books, you get a 5% discount on those two books.

If you buy 3 different books, you get a 10% discount.

If you buy 4 different books, you get a 20% discount.

If you go the whole hog, and buy all 5, you get a huge 25% discount.

Note that if you buy, say, four books, of which 3 are different titles, you get a 10% discount on the 3 that form part of a set, but the fourth book still costs 8 EUR.

Your mission is to write a piece of code to calculate the price of any conceivable shopping basket (containing only Harry Potter books), giving as big a discount as possible.

For example, how much does this basket of books cost?

2 copies of the first book 2 copies of the second book 2 copies of the third book 1 copy of the fourth book 1 copy of the fifth book

Answer: 51.20 EUR

  1. Ruby Strings
  2. Ruby Hashes
  3. Ruby Arrays
  4. Nil
  5. Git Branching
  6. TDD: Red - Green - Refactor
  7. Creating Ruby Classes
  8. What is a ruby module?
  9. Inheritance vs Composition (with examples in Ruby)
  10. Ruby blocks, procs and lambdas
  11. Ruby Enumerators and Enumerable
@zloncar
Copy link

zloncar commented Oct 15, 2013

@michaelpreston
Copy link

@tomajaa
Copy link

tomajaa commented Oct 16, 2013

@technancy
Copy link

@robgough
Copy link

Here are my posts. They're a bit wordy :(

Method Dispatch: https://robgough.silvrback.com/ruby-method-dispatch
GIt: https://robgough.silvrback.com/git-is-scary

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