Hackerrank Day 12: Inheritance

screen-shot-2016-12-23-at-2-10-52-amscreen-shot-2016-12-23-at-2-11-16-am

My Solution in Ruby: 

screen-shot-2016-12-23-at-2-10-26-amscreen-shot-2016-12-23-at-2-10-37-am

This seems so easy in hindsight but I actually spent 3+ hours on it because I didn’t know how to pass numScores into my solution, until Jeff came along! 🙂

In order for a class to process in information, the information (or variable) must be passed in as instance variables.

Also, another thing I learned today:  to get the sum of all elements in an array, use this shorthand method => array.inject(:+)

Advertisements
Hackerrank Day 12: Inheritance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s