Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockets - Hana #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Sockets - Hana #42

wants to merge 1 commit into from

Conversation

hanalways
Copy link

ride share

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? At first I was over-eager to nest as many layers in as possible. I had originally had a large array, which stored a hash of each driver, sorted by a hash of each date, then inside each date was a hash of rider_ids, ratings and cost. As I worked with the questions I evolved it to be simpler, associating the values with their Driver ID keys, and then an array of hashes that had their individual rides.
What was your strategy for going through the data structure and gathering information? Originally I coded for each question, creating iterations inside iterations. When I had answered the first three questions (how many rides, sum cost of rides, average rating) I realized that for the last two I could reuse the code for sum cost of rides and average rating. I refactored my code to create methods for each of the above, so I could re-organize my code for readibility.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I used variables for each of my methods to return a single value to be used and manipulated in a later iteration. I attempted to store any value that I was using more than once in a variable as to make it clear which values I was working with and how in my code.
What kinds of iteration did you use? Did you use .map? If so, when? If not, why, or when would be a good opportunity to use it? I used a total of three iterations - one each loop to calculate outcomes and two map loops for each of my methods.
Were some calculations easier than others? Why? Yes, by creating a series of hashes stored in an array, it was easy to access the total number of rides for each driver. Any information that could execute one or two different Ruby built in methods over an array seemed the easiest to write for.

@hanalways hanalways changed the title Rename worksheet.rb to worksheets.rb Sockets - Hana Feb 19, 2019
@droberts-sea
Copy link

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions yes
Readable code with consistent indentation and reasonable code style yes
Outputs the correct number of rides each driver has given yes
Outputs the total amount of money each driver has made yes
Outputs the average rating for each driver yes
Outputs which driver made the most money yes
Outputs which driver has the highest average rating yes

Great job overall! It's clear to me that the learning goals around working with enumerables and complex data structures have been met. Keep up the hard work!


# average rating for each driver
ratings = driver_ratings(rides).sum / driver_ratings(rides).length
puts " Average rating: #{ratings}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that you used integer division for the average rating, and lost a little precision.

def driver_earnings(input_data)
driver_earnings = input_data.map do |ride|
ride[:cost]
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of methods here to break up and reuse this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants