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

Leaves - Bri #34

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

Leaves - Bri #34

wants to merge 1 commit into from

Conversation

brilatimer
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 considered sorting the data structure with a hash of drivers, with a nested array of rides. I came to realize that the questions and process applied more accurately to the 'rides' as the foundation of the data structures as well as sorting by respective rides.
What was your strategy for going through the data structure and gathering information? I created my own method that would look through my 'master array' (rides) for each unique driver_id. I then adapted the program to be specific to each prompt. Other methods/enumerators I used were: map, sum, length, select, find_index, max.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? It was useful to store the rides unique to each driver in the variable 'driver_rides,' as I could then use that variable to perform various enumeration methods across the questions.
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 did use .map in Q4 and Q5 to create a new array to compare against the array 'driver_ids.'
Were some calculations easier than others? Why? Q1 was the most difficult for me, as it laid the foundation for how I would calculate the following problems. It was the most time consuming. Q4 built upon Q2, as did Q5 upon Q3, so once I recognized that pattern, it was easier to calculate the problems.

@dHelmgren
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

Take a quick look at my comment. I think your code is repeating the same piece of work again and again. Part of learning how to structure your data well is learning how to relieve 'stress' from the code with well thought data. Nice work overall!


# Question 1: The number of rides each driver has given?
def driver_ride_count(driver_id, rides)
driver_rides = rides.select { |ride| ride [:driver_id] == driver_id }

Choose a reason for hiding this comment

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

I think it's interesting that you start this method with select, because it means that the first thing that you do is group all of your rides by driver. This process costs your program a little bit of time as it has to loop through the whole array. Could you remove this extra work by restructuring your data?

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