Skip to content

Sockets - Carla#28

Open
carlabosco wants to merge 1 commit intoAda-C11:masterfrom
carlabosco:master
Open

Sockets - Carla#28
carlabosco wants to merge 1 commit intoAda-C11:masterfrom
carlabosco:master

Conversation

@carlabosco
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? My data structure did not change since the planning phase, although it took me a long time to create code that matched my choice and allowed me to answer the questions.
What was your strategy for going through the data structure and gathering information? I grouped the information by driver and used a .each loop to iterate through the data.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I created variables for some of the information generated inside the loop, but that I wanted to display outside of the loop.
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 group_by, .each, and .map. I used .map twice as an aid to the sum method.
Were some calculations easier than others? Why? Yes! It didn't take me long to figure that the group_by method could be helpful, but it took me a while to figure out how to access the information I needed bellow layers of different structures.

@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 mostly - see inline
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

Good job overall! Your code works well and it is clear to me that the learning goals around working with enumerables and complex data structures were met. Keep up the hard work!

)

# Group rides info by driver
drivers_info = rides.group_by { |ride| ride[:driver_id] }

Choose a reason for hiding this comment

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

Great use of group_by! This is a very clever way to approach this problem.

drivers_info.each do |driver,info|
puts "Driver #{driver} has given #{info.size} rides."
earned = info.map{|ride| (ride[:cost])}.sum
if earned > most_money

Choose a reason for hiding this comment

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

Watch your indentation here.

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