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 - Tatiana #31

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

Sockets - Tatiana #31

wants to merge 2 commits into from

Conversation

tatsqui
Copy link

@tatsqui tatsqui 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? At first it was an array of hashes. It did evolve into a hash with a nested array of hashes. It evolved into this because the questions focused on the drivers and their individual records so grouping the information by driver/driver history seemed like a good way to go.
What was your strategy for going through the data structure and gathering information? My strategy was using mostly .each loops and then using the .sum and .map enumerables to return some quick calculations.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? When I used .map for question 4 to return an array of hashes with name: driver and value: $ total earnings - since it is necessary to store that returned value in a variable in order to use it to later.
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 each loops, map, and sum. For determining who made the most money, I used map to create a smaller array of hashes that I could then use the max_by to determine which driver made the most $ dough.
Were some calculations easier than others? Why? I thought that figuring out totals was easy using the sum enumerable since it only required one step, it seemed more straight forward and thus felt easier.

@tatsqui tatsqui changed the title Ride Share Questions Tatiana Sockets Feb 19, 2019
@tatsqui tatsqui changed the title Tatiana Sockets Sockets - Tatiana Feb 19, 2019
@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, see comments
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

Overall | You should use Git more! 2 commits is slim!

all_averages = ride_share.map do |driver, rides|
{ name: driver, average: rides.sum do |record|
((record[:rating].to_f) / rides.length).round(2)
end }

Choose a reason for hiding this comment

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

This is mostly easy to read, but be aware, the { can be on it's own line or with the thing it's attached to. usually you'd see this formatted:

all_averages = ride_share.map do |driver, rides|{ 
  name: driver, average: rides.sum do |record|
    ((record[:rating].to_f) / rides.length).round(2)
  end 
}end

{ name: driver, most_money_day: array.max_by do |record|
record[:cost]
end }
end

Choose a reason for hiding this comment

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

Indentation got a bit out of hand 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