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

Update worksheet.rb #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

crypt0kitty
Copy link

Assignment Submission: Ride Share

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why?
What was your strategy for going through the data structure and gathering information?
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful?
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?
Were some calculations easier than others? Why?

Copy link
Collaborator

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Nice work Sandy, you hit the learning goals here. Well done. I do think you should consider:

  1. Using Enumerable methods. They could help you dry things up a bit.
  2. Creating your own methods to break things down and for practice.

# Which layers are nested in each other?
# Which layers of data "have" within it a different layer?
# Which layers are "next" to each other?
all_drivers = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 , your indentation is a bit odd however.

Comment on lines +97 to +100
# all_drivers.each do |driver|
# puts driver[:driver_id] + " has given" + " " + driver[:rides].length.to_s + " " + "rides."
# end

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 , however next time uncomment what's working so I can test it easily.

Comment on lines +102 to +112
# all_drivers.each do |driver|
# total_money_made = 0
# driver_id = driver[:driver_id]
# # p driver
#
# driver[:rides].each do |num|
# ride_cost = num[:cost]
# total_money_made += ride_cost
# end
# puts "#{driver_id} earned a total of: $#{total_money_made}."
# end
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 , check your indentation here and I suggest using either the .sum_by or .reduce methods to calculate the totals.

Comment on lines +115 to +125
# all_drivers.each do |driver|
# driver_id = driver[:driver_id]
# ride_count = driver[:rides].length
# sum = 0
#
# driver[:rides].each do |num|
# ride_rating = num[:rating]
# sum += ride_rating
# end
# puts "#{driver_id} has an average rating of #{sum/ride_count.to_f}."
# end
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 , again I suggest using sum or reduce here as well.

Comment on lines +130 to +142
# total_money_made = 0
# driver_id = driver[:driver_id]
#
# driver[:rides].each do |num|
# ride_cost = num[:cost]
# total_money_made += ride_cost
# end
# if highest_earnings < total_money_made
# highest_earnings = total_money_made
# highest_earner_driver_id = driver_id
# end
# end
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a great place to use the max method

@crypt0kitty
Copy link
Author

Good feedback, thanks

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