From 2d1a6b33bef0cb8a9295b3995115d6108c16fe55 Mon Sep 17 00:00:00 2001 From: mirabellemorah Date: Tue, 21 Jul 2026 16:28:04 +0100 Subject: [PATCH 1/4] 1-3 solving --- jq/script-01.sh | 4 ++++ jq/script-02.sh | 2 ++ jq/script-03.sh | 2 ++ 3 files changed, 8 insertions(+) diff --git a/jq/script-01.sh b/jq/script-01.sh index 95827f688..f947ded1f 100755 --- a/jq/script-01.sh +++ b/jq/script-01.sh @@ -5,3 +5,7 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the name of the person. # Your output should be exactly the string "Selma", but should not contain any quote characters. + +# cat person.json | jq -r .name + +jq -r '.name' person.json \ No newline at end of file diff --git a/jq/script-02.sh b/jq/script-02.sh index 21544d67b..66a56aa3d 100755 --- a/jq/script-02.sh +++ b/jq/script-02.sh @@ -5,3 +5,5 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the address of the person, all on one line, with a comma between each line. # Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters. + +jq -r '.address | join(", ")' person.json \ No newline at end of file diff --git a/jq/script-03.sh b/jq/script-03.sh index 3566f03ba..7f1b4fa57 100755 --- a/jq/script-03.sh +++ b/jq/script-03.sh @@ -5,3 +5,5 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the name of the person, then a comma, then their profession. # Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters. + +jq -r -j '.name .profession' person.json \ No newline at end of file From e2b04224aef61cc0c84140952d6712a23517faa4 Mon Sep 17 00:00:00 2001 From: mirabellemorah Date: Tue, 21 Jul 2026 18:57:10 +0100 Subject: [PATCH 2/4] Up to 6 done --- jq/script-03.sh | 2 +- jq/script-04.sh | 2 ++ jq/script-05.sh | 4 ++++ jq/script-06.sh | 3 +++ jq/script-07.sh | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jq/script-03.sh b/jq/script-03.sh index 7f1b4fa57..880729fac 100755 --- a/jq/script-03.sh +++ b/jq/script-03.sh @@ -6,4 +6,4 @@ set -euo pipefail # TODO: Write a command to output the name of the person, then a comma, then their profession. # Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters. -jq -r -j '.name .profession' person.json \ No newline at end of file +jq -r '[.name, .profession] | join(", ")' person.json \ No newline at end of file diff --git a/jq/script-04.sh b/jq/script-04.sh index 015997e18..756dd6702 100755 --- a/jq/script-04.sh +++ b/jq/script-04.sh @@ -6,3 +6,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player, one per line. # Your output should contain 6 lines, each with just one word on it. # Your output should not contain any quote characters. + +jq -r '.[].name' scores.json \ No newline at end of file diff --git a/jq/script-05.sh b/jq/script-05.sh index 993fc9ee3..1af7beedc 100755 --- a/jq/script-05.sh +++ b/jq/script-05.sh @@ -5,3 +5,7 @@ set -euo pipefail # The input for this script is the scores.json file. # TODO: Write a command to output the names of each player, as well as their city. # Your output should contain 6 lines, each with two words on it. + +# jq -r '.[] | [.name, .city] | join(" ")' scores.json + +jq -r '.[] | "\(.name) \(.city)"' scores.json \ No newline at end of file diff --git a/jq/script-06.sh b/jq/script-06.sh index 8b6e74c52..83b85c03b 100755 --- a/jq/script-06.sh +++ b/jq/script-06.sh @@ -6,3 +6,6 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their first attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 1" with no quotes. + +jq -r '.[] | "\(.name) \(.scores[0])"' scores.json + diff --git a/jq/script-07.sh b/jq/script-07.sh index d43f93d1b..1f1d80342 100755 --- a/jq/script-07.sh +++ b/jq/script-07.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their last attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 4" with no quotes. + From 9341ff524351c1f4bf5b590d9221a955fb949592 Mon Sep 17 00:00:00 2001 From: mirabellemorah Date: Tue, 21 Jul 2026 19:30:02 +0100 Subject: [PATCH 3/4] All jq tasks done --- jq/script-06.sh | 1 + jq/script-07.sh | 1 + jq/script-08.sh | 2 ++ jq/script-09.sh | 2 ++ jq/script-10.sh | 4 ++++ jq/script-11.sh | 2 ++ 6 files changed, 12 insertions(+) diff --git a/jq/script-06.sh b/jq/script-06.sh index 83b85c03b..9b321f79b 100755 --- a/jq/script-06.sh +++ b/jq/script-06.sh @@ -9,3 +9,4 @@ set -euo pipefail jq -r '.[] | "\(.name) \(.scores[0])"' scores.json + diff --git a/jq/script-07.sh b/jq/script-07.sh index 1f1d80342..ea187a89e 100755 --- a/jq/script-07.sh +++ b/jq/script-07.sh @@ -7,3 +7,4 @@ set -euo pipefail # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 4" with no quotes. +jq -r '.[] | "\(.name) \(.scores[-1])"' scores.json \ No newline at end of file diff --git a/jq/script-08.sh b/jq/script-08.sh index 6671fd1ba..2a2597390 100755 --- a/jq/script-08.sh +++ b/jq/script-08.sh @@ -6,3 +6,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the number of times they've played the game. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 3" with no quotes. + +jq -r '.[] | "\(.name) \(.scores | length)"' scores.json \ No newline at end of file diff --git a/jq/script-09.sh b/jq/script-09.sh index c2536a536..219ca4b47 100755 --- a/jq/script-09.sh +++ b/jq/script-09.sh @@ -6,3 +6,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the total scores from all of their games added together. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 15" with no quotes. + +jq -r '.[] | "\(.name) \(.scores | add)"' scores.json \ No newline at end of file diff --git a/jq/script-10.sh b/jq/script-10.sh index 8e9d75f07..6c64c1a22 100755 --- a/jq/script-10.sh +++ b/jq/script-10.sh @@ -5,3 +5,7 @@ set -euo pipefail # The input for this script is the scores.json file. # TODO: Write a command to output the total of adding together all players' first scores. # Your output should be exactly the number 54. + +# jq -r '.[] | "\(.name) \(.scores[0] | add)"' scores.json + +jq -r '[.[] | .scores[0]] | add' scores.json \ No newline at end of file diff --git a/jq/script-11.sh b/jq/script-11.sh index d2337a6b2..17773be7e 100755 --- a/jq/script-11.sh +++ b/jq/script-11.sh @@ -5,3 +5,5 @@ set -euo pipefail # The input for this script is the scores.json file. # TODO: Write a command to output the total of adding together all scores from all games from all players. # Your output should be exactly the number 164. + +jq -r '[.[] | .scores[]] | add' scores.json \ No newline at end of file From 643515a821b1719f88c3a0f869149cdaf2c2ff19 Mon Sep 17 00:00:00 2001 From: mirabellemorah Date: Sun, 9 Aug 2026 18:51:31 +0100 Subject: [PATCH 4/4] Ignore these stretch tests --- jq/jq-priv-tests/persona.json | 26 ++++++++++++++++++++++++++ jq/jq-priv-tests/t.sh | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 jq/jq-priv-tests/persona.json create mode 100644 jq/jq-priv-tests/t.sh diff --git a/jq/jq-priv-tests/persona.json b/jq/jq-priv-tests/persona.json new file mode 100644 index 000000000..f011690a1 --- /dev/null +++ b/jq/jq-priv-tests/persona.json @@ -0,0 +1,26 @@ +[ + { + "name": "Daniel", + "score": 100 + }, + { + "name": "Kristina", + "score": 120 + }, + { + "name": "Iulia", + "score": 95 + }, + { + "name": "Aleks", + "score": 190 + }, + { + "name": "Daniel", + "score": 80 + }, + { + "name": "Fatima", + "score": 110 + } +] diff --git a/jq/jq-priv-tests/t.sh b/jq/jq-priv-tests/t.sh new file mode 100644 index 000000000..0a76b957f --- /dev/null +++ b/jq/jq-priv-tests/t.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -euo pipefail + +# The input for this script is the persona.json file. +# What was the name of the first person to play the game? +# What was the name of the last person to play the game? +# Who had the highest score? +# The names of everyone who played the game directly after Daniel? + +# cat person.json | jq -r .name +# jq [flags] 'filter' [file] + +jq -r '.[0] | .name' persona.json +jq -r '.[-1] | .name' persona.json +jq -r '[.[] | .score] | max' persona.json +jq -r 'max_by(.score) | .name' persona.json