-
Notifications
You must be signed in to change notification settings - Fork 9
This is our answer to the problem set #6
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
zoeloh
wants to merge
10
commits into
lyy005:master
Choose a base branch
from
zoeloh: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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ba41b7b
Soren Favorite movies
sorenh25 f692771
zoes movies
zoeloh a811ebe
new movie zoes list
zoeloh 63f5d61
Revised order of movies Soren
sorenh25 ee76af0
Conflict solved
sorenh25 623facb
problem 1
zoeloh 241ca76
Part 2 of challenge complete
sorenh25 d6c749e
Zoe and Soren conflicts resolved
sorenh25 6bf79af
Part 3 by Soren and Zoe
sorenh25 7956b94
Final submission of solution
zoeloh 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,7 @@ | ||
| Harry Potter 3 | ||
| Harry Potter 1 | ||
| Harry potter 2 | ||
| the notebook | ||
| wild | ||
| younger | ||
|
|
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,78 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ################################################################################ | ||
| # Part 1 by Zoe | ||
| #!/usr/bin/env bash | ||
| #unique gender and years experience combinations | ||
| #Usage wages.csv | ||
|
|
||
| cat wages.csv | tail -n +2 | tr -s "," | cut -d "," -f 1,2 | sed 's/,/ /' | sort -b -k1,1 -k2,2n | uniq >>problem.txt | ||
|
|
||
| ################################################################################ | ||
| #Part 2 by Soren | ||
|
|
||
| HEADLINE=$(head -n 1 wages.csv | awk -F ',' '{printf("%s %s %s\n",$1, $2, $4)}') | ||
| HIGHEST=$(tail -n +2 wages.csv | sort -k 4 -t ',' -n | tail -n 1 | awk -F ',' '{printf("%s %s %s\n",$1, $2, $4)}') | ||
| LOWEST=$(tail -n +2 wages.csv | sort -k 4 -t ',' -n | head -n 1 | awk -F ',' '{printf("%s %s %s\n",$1, $2, $4)}') | ||
|
|
||
| echo "-------------" | ||
| echo "Highest earner" | ||
| echo $HEADLINE | ||
| echo $HIGHEST | ||
| echo "-------------" | ||
| echo "Lowest earner" | ||
| echo $HEADLINE | ||
| echo $LOWEST | ||
| echo "-------------" | ||
|
|
||
| TOP10=$(tail -n +2 wages.csv | sort -k 4 -t ',' -n | tail -n 10 | awk -F ',' '{printf("%s \n",$1)}') | ||
| COUNTER=$((0)) | ||
| for GENDER in $TOP10 | ||
| do | ||
| if [ $GENDER == "female" ] | ||
| then | ||
| ((COUNTER++)) | ||
| fi | ||
| done | ||
|
|
||
|
|
||
| echo "Number of women among top 10 earners:" | ||
| echo $COUNTER | ||
| echo "-------------" | ||
|
|
||
| ################################################################################ | ||
| #Part 3 by Soren and Zoe | ||
|
|
||
| COUNTERHIGHSCHOOL=$((0)) | ||
| HIGHSCHOOLTOTALWAGES=$((0)) | ||
| COUNTERCOLLEGE=$((0)) | ||
| COLLEGETOTALWAGES=$((0)) | ||
|
|
||
| for LINE in $(cat wages.csv) | ||
| do | ||
|
|
||
| SCHOOLYEARS=$(echo $LINE | awk -F ',' '{printf("%d",$3)}') | ||
| if [ $SCHOOLYEARS == 12 ] | ||
| then | ||
| ((COUNTERHIGHSCHOOL++)) | ||
| WAGE=$(echo $LINE | awk -F ',' '{printf("%f",$4)}') | ||
| HIGHSCHOOLTOTALWAGES=$(echo "$HIGHSCHOOLTOTALWAGES + $WAGE" | bc) | ||
| fi | ||
|
|
||
| if [ $SCHOOLYEARS == 16 ] | ||
| then | ||
| ((COUNTERCOLLEGE++)) | ||
| WAGE=$(echo $LINE | awk -F ',' '{printf("%f",$4)}') | ||
| COLLEGETOTALWAGES=$(echo "$COLLEGETOTALWAGES + $WAGE" | bc) | ||
| fi | ||
|
|
||
| done | ||
|
|
||
| AVGHIGHSCHOOLWAGES=$(echo "$HIGHSCHOOLTOTALWAGES / $COUNTERHIGHSCHOOL" | bc -l) | ||
| AVGCOLLEGEWAGES=$(echo "$COLLEGETOTALWAGES / $COUNTERCOLLEGE" | bc -l) | ||
| WAGEDIFFERENCE=$(echo "$AVGCOLLEGEWAGES - $AVGHIGHSCHOOLWAGES" | bc -l) | ||
|
|
||
| echo "$COUNTERHIGHSCHOOL high school graduates (12 years) earned an average of $AVGHIGHSCHOOLWAGES USD/h" | ||
| echo "$COUNTERCOLLEGE college graduates (16 years) earned an average of $AVGCOLLEGEWAGES USD/h" | ||
| echo "Wage difference: $WAGEDIFFERENCE" | ||
| echo "-------------" | ||
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.
Good! Nice format for the output