Skip to content

Leaves - Yitgop#24

Open
rinostar wants to merge 1 commit intoAda-C12:masterfrom
rinostar:master
Open

Leaves - Yitgop#24
rinostar wants to merge 1 commit intoAda-C12:masterfrom
rinostar:master

Conversation

@rinostar
Copy link

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? I was originally planning to structure it as hashes within hashes within a hash; I later changed it to hashes within arrays within a hash
What was your strategy for going through the data structure and gathering information? Since I realize I need to sum values from a specific key-value pair at the lowest level of hashes for multiple times, I created a function to do that to avoid duplicate codes
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? In my function, I store the final result in a variable "result; otherwise, I will not be able to return it for calling 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 '.map', '.sum', '.max', '.merge!'; I used '.map' in my function to iterate return an array of specific values from my data structure
Were some calculations easier than others? Why? many calculations became easier with the introduction of enumerable functions; instead of writing the function form the ground, these build-in ruby functions allows me to return calculation result in much more condense codes. e.g. '.max'

@beccaelenzil
Copy link

beccaelenzil commented Aug 15, 2019

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions yes
Readable code with consistent indentation and reasonable code style yes
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 Great work on this assignment. Please review the inline comments for some suggestions about format, the use of methods, and ways to make your code flexible. Overall your did a great job and it is clear that the learning goals of working with complex data structures and enumerables were met.

@@ -0,0 +1,125 @@
LIBER = {

"DR0001" => [

Choose a reason for hiding this comment

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

While you don't end up needed the rider_id information, you should include this information in your data structure so as not to lose any information that was stored in the csv.

}

],

Choose a reason for hiding this comment

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

You do not need to include line spaces between hashes and arrays separated by commas.

puts "\n3. The average rating for each driver:"
m = 1
ratings = {}
4.times do

Choose a reason for hiding this comment

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

instead of hardcoding the number 4 in here you should use the length of your data structure LIBER.keys.length so that your code is flexible.


}

def super_sum(hash, array, key)

Choose a reason for hiding this comment

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

Consider adding one line comments to outline your code and explain what each section is doing.

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