forked from AdaGold/ride-share
-
Notifications
You must be signed in to change notification settings - Fork 47
Leaves_Ga-Young #42
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
Open
gyjin
wants to merge
1
commit into
Ada-C12:master
Choose a base branch
from
gyjin:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Leaves_Ga-Young #42
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Ga-Young Jin, Cohort 12 | ||
| # Wednesday, August 7th, 2019 | ||
| # Week 1 | ||
|
|
||
| rideshare_data = [ | ||
| [ | ||
| { driver: "DR0001", | ||
| date: "3rd Feb 2016", | ||
| cost: 10, | ||
| rider: "RD0003", | ||
| rating: 3 | ||
| }, | ||
| { driver: "DR0001", | ||
| date: "3rd Feb 2016", | ||
| cost: 30, | ||
| rider: "RD0015", | ||
| rating: 4 | ||
| }, | ||
| { driver: "DR0001", | ||
| date: "5th Feb 2016", | ||
| cost: 45, | ||
| rider: "RD0003", | ||
| rating: 2 | ||
| } | ||
| ], | ||
| [ | ||
| { driver: "DR0002", | ||
| date: "3rd Feb 2016", | ||
| cost: 25, | ||
| rider: "RD0073", | ||
| rating: 5 | ||
| }, | ||
| { driver: "DR0002", | ||
| date: "4th Feb 2016", | ||
| cost: 15, | ||
| rider: "RD0013", | ||
| rating: 1 | ||
| }, | ||
| { driver: "DR0002", | ||
| date: "5th Feb 2016", | ||
| cost: 35, | ||
| rider: "RD0066", | ||
| rating: 3 | ||
| }, | ||
| ], | ||
| [ | ||
| { driver: "DR0003", | ||
| date: "4th Feb 2016", | ||
| cost: 5, | ||
| rider: "RD0066", | ||
| rating: 5 | ||
| }, | ||
| { driver: "DR0003", | ||
| date: "5th Feb 2016", | ||
| cost: 50, | ||
| rider: "RD0003", | ||
| rating: 2 | ||
| } | ||
| ], | ||
| [ | ||
| { driver: "DR0004", | ||
| date: "3rd Feb 2016", | ||
| cost: 5, | ||
| rider: "RD0022", | ||
| rating: 5 | ||
| }, | ||
| { driver: "DR0004", | ||
| date: "4th Feb 2016", | ||
| cost: 10, | ||
| rider: "RD0022", | ||
| rating: 4 | ||
| }, | ||
| { driver: "DR0004", | ||
| date: "5th Feb 2016", | ||
| cost: 20, | ||
| rider: "RD0073", | ||
| rating: 5 | ||
| } | ||
| ] | ||
| ] | ||
|
|
||
| # number of drives each driver has given | ||
| puts "Number of drives each driver has given:" | ||
| rideshare_data.each do |drives| | ||
| puts "#{drives[0][:driver]}: #{drives.length}" | ||
| end | ||
|
|
||
| # total amount of money each driver has made | ||
| puts "Total amount of money each driver made:" | ||
| rideshare_data.each do |drives| | ||
| total_money = 0 | ||
| drives.each do |price| | ||
| total_money = total_money + price[:cost] | ||
| end | ||
| puts "#{drives[0][:driver]}: #{total_money}" | ||
| end | ||
|
|
||
| # average rating for each driver | ||
| puts "The average rating for each driver:" | ||
| rideshare_data.each do |drives| | ||
| total_rating = 0 | ||
| drives.each do |ride| | ||
| total_rating = total_rating + ride[:rating] | ||
| end | ||
| avg_rating = total_rating / drives.length.to_f | ||
| puts "#{drives[0][:driver]}: #{sprintf('%.2f', avg_rating)}" | ||
| end | ||
|
|
||
| # driver that made the most money | ||
| most_money_driver = "" | ||
| money_made_array = Array.new | ||
| rideshare_data.each do |drives| | ||
| money_made = 0 | ||
| drives.each do |ride| | ||
| money_made = money_made + ride[:cost] | ||
| end | ||
| money_made_array << money_made | ||
| end | ||
| most_money = 0 | ||
| money_made_array.each do |total| | ||
| if total > most_money | ||
| most_money_driver = rideshare_data[0][0][:driver] | ||
| end | ||
| end | ||
|
|
||
| puts "The driver that made the most money: #{most_money_driver}." | ||
|
|
||
| # driver that has the highest average rating | ||
| highest_avg_rating_driver = "" | ||
| rideshare_data.each do |drives| | ||
| highest_avg_rating = 0 | ||
| avg_rating_array = Array.new | ||
| total_rating = 0 | ||
| drives.each do |ride| | ||
| total_rating = total_rating + ride[:rating] | ||
| end | ||
| avg_rating_array << total_rating / drives.length.to_f | ||
| total_rating = 0 | ||
| avg_rating_array.each do |avg| | ||
| if avg > highest_avg_rating | ||
| highest_avg_rating_driver = drives[0][:driver] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| puts "The driver with the highest average rating: #{highest_avg_rating_driver}." | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have these arrays grouped by driver, but chose to leave the data inside these hashes, even though it's redundant. When I see groupings like this, it makes me think the outermost layer should probably be a hash!