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

Time - Alicia #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Time - Alicia #29

wants to merge 1 commit into from

Conversation

aecombs
Copy link

@aecombs aecombs commented Feb 10, 2020

Assignment Submission: Ride Share

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? I had originally had all of my drivers within another hash called DRIVER_ID, which didn't make much sense since it only had one key. I decided to reduce that layer.
What was your strategy for going through the data structure and gathering information? I knew I'd be using loops, a lot. So I did just that! I didn't use any methods since I wouldn't be needing to access data in this way with multiple hashes or anything.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? For the last (optional) question especially, I didn't know how I would be able to accomplish what was needed unless I created an entirely new hash. I did get help on this because I was struggling with using .reduce(), but it turned out okay in the end.
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() a LOT, and a bunch of .reduce(). I used .include?() once. The use of .each() is pretty self explanatory. For .reduce(), I now knew it existed so I wanted to try to use it. It was a painful, struggle-bus journey but I mostly used it to get highest values.
Were some calculations easier than others? Why? Yes! Using .reduce() to help me calculate the averages was super easy, compared to getting the highest value of an array. It was pretty familiar and made sense to me already, so I didn't struggle to wrap my head around anything.

@kaidamasaki
Copy link

Ride Share

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly creates, reads, and modifies variables ✔️
Correctly creates and accesses arrays ✔️
Correctly creates and accesses hashes ✔️
Reasonably organizes large amounts of related data into nested arrays and hashes ✔️
Correctly iterates through a nested data structure using loops and/or Enumerable methods ✔️
Reasonably organizes small pieces of code into methods, and calls/invokes those methods Didn't make any new methods.

Functional Requirements

Functional Requirement yes/no
To the terminal, the program outputs the correct number of rides each driver has given ✔️
... outputs the total amount of money each driver has made ✔️
... outputs the average rating for each driver ✔️
... outputs which driver made the most money ✔️
... outputs which driver has the highest average rating ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 4+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 2-3 in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0,1 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Your code was pretty solid aside from not defining your own methods. I especially like how you made such good use of reduce!

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized Using methods would really help with making your program more organized.

# The total amount of money each driver has made
drivers_earnings = {}
drivers_rides_data.each do |driver, rides_array|
total_money = rides_array.reduce(0) { |sum, ride| sum + ride[:COST] }

Choose a reason for hiding this comment

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

.reduce is really cool and powerful but you can use .sum for simple things like this if you'd like.

   total_money = rides_array.sum { |ride| ride[:COST] }



# Which driver made the most money?
top_earner = drivers_earnings.reduce([0, 0]) do |best, (driver, earnings)|

Choose a reason for hiding this comment

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

Nice use of .reduce 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