Skip to content

Update worksheet.rb#45

Open
nerdyistrendy wants to merge 1 commit intoAda-C14:masterfrom
nerdyistrendy:master
Open

Update worksheet.rb#45
nerdyistrendy wants to merge 1 commit intoAda-C14:masterfrom
nerdyistrendy:master

Conversation

@nerdyistrendy
Copy link

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 tried [{driverid:[]}, but I found it hard to access
What was your strategy for going through the data structure and gathering information? To document each step and write down on paper
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? to initialize variable to get the maximum earnings and highest ratings so i can access them outside the block
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 as I need to go through each of the elements. It would be useful to use .map when you need to change the data
Were some calculations easier than others? Why? I had the same calculation

Copy link
Collaborator

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Nice work Li, you hit the learning goals here. Well done.

I do think this could be broken up into methods making the steps easier to read and understand.

# into this data structure, such as "DR0004"
# and "3rd Feb 2016" and "RD0022"

rides = [{driver_id:"DR0001", date:["3rd Feb 2016", "3rd Feb 2016", "5th Feb 2016"], cost:[10, 30, 45], ride_id:["RD0003","RD0015","RD0003"], rating:[3, 4, 2]},
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 , this works, but you have basically 3 parallel arrays in the dates, costs, ride_id and ratings. You have to keep the indexes aligned.

This works for the given examples, but for more general-purpose problems this might work as well. Each entry is labeled and relatively easy identify what value goes with each item.

Suggested change
rides = [{driver_id:"DR0001", date:["3rd Feb 2016", "3rd Feb 2016", "5th Feb 2016"], cost:[10, 30, 45], ride_id:["RD0003","RD0015","RD0003"], rating:[3, 4, 2]},
driver_data = {
dr0001: [
{
date: "3rd Feb 2016",
cost: [10],
ride_id: "RD0003",
rating: 3,
}
...
],
dr0002: ...

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