Skip to content

Create amandaungco-rideshare.rb#28

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

Create amandaungco-rideshare.rb#28
unkcodesquick wants to merge 1 commit into
Ada-C10:masterfrom
unkcodesquick:master

Conversation

@unkcodesquick

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? initially my data structure was pretty complicated, I tried to have a hash of hashes of hashes with the average ratings and total money made built into the data structure. I simplified my data structure to more easily pull the values out of it.
What was your strategy for going through the data structure and gathering information? I looped through the data I manually entered with the .each method and then called on various enumerable methods we learned in class on friday to loop through the array of hashes. I created new hashes for the different variables I was searching for and pushed the appropriate data to the hashes.
What was an example of something that was necessary to store in a variable? What was the scope of each of that variables? Why? I created a variable for the total ratings and average rating, so it would be easier and clearer for the program to calculate a value. The scoop of these variables is just within the .each loop
What kinds of iteration did you use? Did you use .map? I used .each, .reduce and .max_by. I didn't use .map.
Were some calculations easier than others? Why? Some calculations were easier than others, I think the way I established my data structure initially helped a lot. For each, the hash of arrays, made it very simple to calculate the number of rides each driver completed by simply calling array.length to calculate the # of rides.

@dHelmgren

Copy link
Copy Markdown

Good use of enumerables max_by and reduce! Structure of the data is well thought out as well. See my comment, It can be hard to read code that is as densely packed as yours is, so consider adding line breaks to help guide the reader's eye.

Comment thread amandaungco-rideshare.rb
drivers_to_average_rating = {}
drivers_to_best_day = {}

drivers_raw_data.each do |driver, rides|

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I find tightly packed text like this very hard to read. Adding a blank line between blocks of related data manipulation is a good way to keep code readable.

Comment thread amandaungco-rideshare.rb
average_rating = total_ratings.to_f/rides.length
drivers_to_average_rating[driver] = average_rating
puts "#{driver}: total rides: #{rides.length}\n total earnings: $#{total_money_earned}\n average rating:#{average_rating.round(2)}"
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Try to keep your end indented at the same line as the start of the loop!

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