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

Ports - Amy M #46

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

Ports - Amy M #46

wants to merge 1 commit into from

Conversation

amyesh
Copy link

@amyesh amyesh commented Feb 19, 2019

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? I landed on sorting by driver pretty immediately - at one point i added more information than was given, i.e. "driver_num: 1" but felt that that wasn't as interesting as if I could just use the information I was given.
What was your strategy for going through the data structure and gathering information? I used the map method to loop through the array of nested hashes.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I stored the resulting arrays I created from my methods into variables which I could then loop through to print.
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 all map methods because I wanted to keep all original data in the hash, and create new arrays to hold new data.
Were some calculations easier than others? Why? The calculations were harder when I needed to keep tabs on two pieces of information - the max average rating and the driver id simultaneously

@tildeee
Copy link

tildeee commented Feb 25, 2019

Ride Share

What We're Looking For

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

Hi Amy! Great job on this project.

Your code style is great and your strategies were what I was looking for! Great job on getting all of the iteration, and using methods from Enumerable.

I'd like to give some very vague questions as "food for thought" (I know that we don't want to ever leave you with vague questions, but I'm going to allow ourselves to do this for this project):

  • Your data structure has the following things nested within a driver stored as separate arrays: rides, cost, ratings, and riders. This makes sense because they happen in an ordered sequence. However, would there ever be a time in which a ride (represented in the rides array) will ever NOT have a cost? Will ever NOT have a rating? Will ever NOT have a rider? Separate arrays give us an accurate relationship between these ride-attributes and driver, but I think there may be ways to express the relationship between rides and their cost, rider, etc. with a data structure, too.
  • Writing methods was not a requirement for this project, but it may be nice to one day look back at this project and think about what methods could be pulled out, for the sake of organization/having a name for different pieces of logic.

That being said, you did great on this project and calculated everything correctly and got all of the correct answers. Well done!

puts "Total number of rides for each driver:"
i = 0
rideshare_info.each do |driver|
puts "Driver #{(driver[:driver])[-1]}: #{number_of_rides[i]}"
Copy link

Choose a reason for hiding this comment

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

I like the care and effort you put into making this output more readable to humans :) You could have just printed id but instead you put in work to give it a nice number. I want to be clear that this wasn't a requirement, but it sure was nice! :D


puts "Total number of rides for each driver:"
i = 0
rideshare_info.each do |driver|
Copy link

Choose a reason for hiding this comment

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

In order to keep track of the index so you could use it to index into another array, you made an i variable. You probably will be happy to know that something exists for you to use in the future: each_with_index. This gives you a reference to a second iteration variable besides driver, and you use it like this:

number_of_rides = driver_rides(rideshare_info)

puts "Total number of rides for each driver:"
rideshare_info.each do |driver, i|
  puts "Driver #{(driver[:driver])[-1]}: #{number_of_rides[i]}"
end


def driver_pay(info)
paychecks = info.map do |driver|
(driver[:cost]).reduce(:+)
Copy link

Choose a reason for hiding this comment

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

(driver[:cost]).reduce(:+) is the same as (driver[:cost]).sum, in case you wanted even another approach to this

paycheck = info.map do |driver|
[(driver[:cost]).reduce(:+), driver[:driver]]
end
most_cash = paycheck.max
Copy link

Choose a reason for hiding this comment

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

Nice 👍 I like this line, and this method in general :D

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