Skip to content

Branches - Brianna#39

Open
brikemp wants to merge 1 commit intoAda-C12:masterfrom
brikemp:patch-1
Open

Branches - Brianna#39
brikemp wants to merge 1 commit intoAda-C12:masterfrom
brikemp:patch-1

Conversation

@brikemp
Copy link

@brikemp brikemp commented Aug 12, 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, I thought about structuring the data in fewer layers (array of hashes where the hashes represented each ride/row of data). The structure evolved because I realized this would make it very difficult to group data in an easy manner and that I would have to iterate excessively to pull out/compare data.
What was your strategy for going through the data structure and gathering information? Wherever possible I tried to use the driver id to reference the data in the hash that I needed. When that wasn't possible and I needed to go a layer deeper I would often find the info I needed and then use the index of that data to get the final result.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful The total amount that each driver made (#2) was necessary to store in a hash to give #4 something to reference and prevent re-doing all of the code in #2
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 primarily used .each and .each_with_index to get to the answers I needed. I had the opportunity to use .map in a couple of places, specifically where I used .values and .keys - I could have achieved the same thing using .map, if needed.
Were some calculations easier than others? Why? Problems 1,4, and 5 were the easiest, 2 and 3 were in the middle, and the optional problem was the hardest. 1 was easy because the ansers were easily accessible in my data structure. 4 and 5 were also on the easy side because the data was readily available from previous problems. For problems 2 and 3, the data was also pretty easily accessible; however, I did need to do some research online to find the .each_with_index method, which helped simplify the problem a lot. The optional problem was the hardest because the data for this problem was not easily accessible and I needed to create separate data structures to be able to get what I needed

@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 yes - watch your variable naming
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! While I've left a few inline comments below, 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!

puts "Number of rides each driver has given: "
drivers.each do |key, value|
puts " #{key} has given #{value.length} rides"
end

Choose a reason for hiding this comment

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

Are there more descriptive names you could use for these block parameters than key and value? Something like driver_id and trips might be a good choice.

total = 0
value.each_with_index do |(driver), index|
cost = value[index][:cost]
total += cost

Choose a reason for hiding this comment

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

Wouldn't value[index] be the same as the variable driver? Also, I think that trip might be a better name for that variable.

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