Skip to content

Commit 0bff639

Browse files
committed
Add jq commands to output player stats and total scores
- script-08.sh: Output each player's name and number of games played. - script-09.sh: Output each player's name and total score. - script-10.sh: Output the sum of all players' first scores. - script-11.sh: Output the sum of all scores from all games and players.
1 parent b5f6bfd commit 0bff639

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

jq/script-08.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 3" with no quotes.
9+
10+
jq -r '.[] | "\(.name) \(.scores | length)"' scores.json

jq/script-09.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the total scores from all of their games added together.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 15" with no quotes.
9+
10+
jq -r '.[] | "\(.name) \(.scores | add)"' scores.json

jq/script-10.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output the total of adding together all players' first scores.
77
# Your output should be exactly the number 54.
8+
9+
jq -r '[.[] .scores[0]] | add' scores.json

jq/script-11.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output the total of adding together all scores from all games from all players.
77
# Your output should be exactly the number 164.
8+
9+
jq -r '[.[] .scores | add] | add' scores.json

0 commit comments

Comments
 (0)