Skip to content

Create ride-share.rb - Leanne Rivera#31

Open
leannerivera wants to merge 1 commit into
Ada-C10:masterfrom
leannerivera:master
Open

Create ride-share.rb - Leanne Rivera#31
leannerivera wants to merge 1 commit into
Ada-C10:masterfrom
leannerivera:master

Conversation

@leannerivera

Copy link
Copy Markdown

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? Yes, at first it was a bit more complicated as I wanted to organize each driver info by dates first, but int th end i put that as a key for the rides hash.
What was your strategy for going through the data structure and gathering information? for the general information, i has the method iterate through the array then into the hashes until it plucked each bit of info that i wanted.
What was an example of something that was necessary to store in a variable? What was the scope of each of that variables? Why? scope was really important when determining, for example, the best ratings since comparisons had to be made outside of the scope of the hash iterations in order to be compared to each other.
What kinds of iteration did you use? Did you use .map? I used .each quite a bit. I attempted to use .map first but didn't since I don't believe i needed new arrays based on a previous one at the time.
Were some calculations easier than others? Why? straight sums were easier than averages, just figuring out how to have the program determine what to divide by

@leannerivera leannerivera changed the title Create ride-share.rb Create ride-share.rb - Leanne Rivera Aug 13, 2018
@CheezItMan

Copy link
Copy Markdown

Small Note: You need to work on proper indentation. Feel free to use the keyboard shortcut we put into Atom option-cmd-]. You are also doing some duplication of effort with .sum method calls inside some .each blocks. I like how you structured the data it's a good way to organize it. You also did a good job of breaking things into methods. Overall you hit all the learning goals for the project. Excellent work! I left some notes in your code, let me know if you have questions.

Comment thread ride-share.rb

hash[:rides].each do |hash2|
driver_total << hash2[:cost]
driver_sum = driver_total.sum

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You're running this sum method each time you add a cost to driver_total, to be more efficient only do the sum after you finish adding all the costs to driver_total. Otherwise you're duplicating effort.

You could also use sum_by instead of .each to do this totaling.

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