diff --git a/.github/workflows/sorted.yml b/.github/workflows/sorted.yml new file mode 100644 index 0000000..0de38ff --- /dev/null +++ b/.github/workflows/sorted.yml @@ -0,0 +1,16 @@ +name: Exercise order + +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + call-gha-workflow: + name: Check + uses: exercism/github-actions/.github/workflows/sorted.yml@main + with: + ordering: ".bucket, .lowercase_name" diff --git a/bin/sort-practice-exercises b/bin/sort-practice-exercises new file mode 100644 index 0000000..2ce7c22 --- /dev/null +++ b/bin/sort-practice-exercises @@ -0,0 +1,30 @@ +#!/bin/bash + +die () { echo "$*" >&2; exit 1; } + +(( $# == 2 )) || die "Usage: $0 " +[[ -r $2 ]] || die "$2 is not a readable file" + +tmp=$(mktemp) +jq -r ' + # Bucket by displayed difficulty. 0-3: easy; 4-7: medium; 8-10: hard. + def bucket(i): [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3][i]; + # Code injection to inject the sort literal expression. + def sort: sort_by('"$1"'); + .exercises.practice = ( + .exercises.practice | + # Add displayed difficulty + map(.lowercase_name = (.name | ascii_downcase)) | + map(.bucket = bucket(.difficulty)) | + # Leave hello-world at the top + if .[0].slug == "hello-world" then + [.[0]] + (.[1:] | sort) + else + sort + end | + map(del(.lowercase_name)) | + map(del(.bucket)) + ) +' "$2" > "$tmp" && \ +cat "$tmp" > "$2" +rm "$tmp" diff --git a/config.json b/config.json index 0ec0745..af9414b 100644 --- a/config.json +++ b/config.json @@ -99,6 +99,14 @@ "math" ] }, + { + "slug": "binary-search", + "name": "Binary Search", + "uuid": "7177483a-8370-4d24-81c4-8dfdfd83846d", + "practices": [], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "bob", "name": "Bob", @@ -115,6 +123,14 @@ "prerequisites": [], "difficulty": 2 }, + { + "slug": "dnd-character", + "name": "D&D Character", + "uuid": "eba5ba27-1c8b-485a-8bf4-08df4239a6f3", + "practices": [], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "darts", "name": "Darts", @@ -134,6 +150,14 @@ "math" ] }, + { + "slug": "eliuds-eggs", + "name": "Eliud's Eggs", + "uuid": "e02de36d-defa-495b-8940-6b2a179afc87", + "practices": [], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "gigasecond", "name": "Gigasecond", @@ -191,41 +215,41 @@ "difficulty": 2 }, { - "slug": "nucleotide-count", - "name": "Nucleotide Count", - "uuid": "9b1ae897-b15d-4180-af45-1c69f98a8f34", + "slug": "list-ops", + "name": "List Ops", + "uuid": "f5ade076-6afd-4f03-8916-543cb7f350a1", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "perfect-numbers", - "name": "Perfect Numbers", - "uuid": "659d24f5-1e6d-4622-a2dc-177aecc10fae", + "slug": "nucleotide-count", + "name": "Nucleotide Count", + "uuid": "9b1ae897-b15d-4180-af45-1c69f98a8f34", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "resistor-color", - "name": "Resistor Color", - "uuid": "2af13bc4-76d6-4986-988f-b6acce6aa128", + "slug": "pangram", + "name": "Pangram", + "uuid": "d319360a-afef-4b65-be5f-da45d48367cb", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "resistor-color-duo", - "name": "Resistor Color Duo", - "uuid": "be651c89-5bb7-4842-8fa8-8c65431281a0", + "slug": "perfect-numbers", + "name": "Perfect Numbers", + "uuid": "659d24f5-1e6d-4622-a2dc-177aecc10fae", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "resistor-color-trio", - "name": "Resistor Color Trio", - "uuid": "69121bed-8952-4ca4-a64a-2fab8e94b949", + "slug": "protein-translation", + "name": "Protein Translation", + "uuid": "b61ac6a8-b40d-48ea-8a72-89608506c256", "practices": [], "prerequisites": [], "difficulty": 2 @@ -239,88 +263,49 @@ "difficulty": 2 }, { - "slug": "rna-transcription", - "name": "RNA Transcription", - "uuid": "8db0d097-9758-4671-81ff-fd8111c4fd7d", - "practices": [], - "prerequisites": [], - "difficulty": 2 - }, - { - "slug": "secret-handshake", - "name": "Secret Handshake", - "uuid": "7d6e5c28-7f7a-4d76-8533-390c9cc86586", - "practices": [], - "prerequisites": [], - "difficulty": 2 - }, - { - "slug": "space-age", - "name": "Space Age", - "uuid": "dfb7c4aa-dc52-4973-8c50-f5153ab51406", + "slug": "raindrops", + "name": "Raindrops", + "uuid": "d53f769b-b294-4fb0-a336-881549a15a94", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "strain", - "name": "Strain", - "uuid": "fe975ff0-e374-44c9-910b-740cc3cff4ad", + "slug": "resistor-color", + "name": "Resistor Color", + "uuid": "2af13bc4-76d6-4986-988f-b6acce6aa128", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "sum-of-multiples", - "name": "Sum of Multiples", - "uuid": "8f8697e6-2e8b-47dc-8bd0-747f29b93ae7", - "practices": [], - "prerequisites": [], - "difficulty": 2, - "topics": [ - "math" - ] - }, - { - "slug": "trinary", - "name": "Trinary", - "uuid": "db8c35d3-5203-4b3c-bb58-bd7a42ab2e5d", - "practices": [], - "prerequisites": [], - "difficulty": 2, - "status": "deprecated", - "topics": [ - "math" - ] - }, - { - "slug": "two-fer", - "name": "Two-Fer", - "uuid": "b186e735-f638-4836-97c1-9c78c5e0078e", + "slug": "resistor-color-duo", + "name": "Resistor Color Duo", + "uuid": "be651c89-5bb7-4842-8fa8-8c65431281a0", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "raindrops", - "name": "Raindrops", - "uuid": "d53f769b-b294-4fb0-a336-881549a15a94", + "slug": "resistor-color-trio", + "name": "Resistor Color Trio", + "uuid": "69121bed-8952-4ca4-a64a-2fab8e94b949", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "eliuds-eggs", - "name": "Eliud's Eggs", - "uuid": "e02de36d-defa-495b-8940-6b2a179afc87", + "slug": "reverse-string", + "name": "Reverse String", + "uuid": "a6a5838c-f35c-4fd2-ab80-62d6a61dd6b3", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "reverse-string", - "name": "Reverse String", - "uuid": "a6a5838c-f35c-4fd2-ab80-62d6a61dd6b3", + "slug": "rna-transcription", + "name": "RNA Transcription", + "uuid": "8db0d097-9758-4671-81ff-fd8111c4fd7d", "practices": [], "prerequisites": [], "difficulty": 2 @@ -342,37 +327,48 @@ "difficulty": 2 }, { - "slug": "protein-translation", - "name": "Protein Translation", - "uuid": "b61ac6a8-b40d-48ea-8a72-89608506c256", + "slug": "secret-handshake", + "name": "Secret Handshake", + "uuid": "7d6e5c28-7f7a-4d76-8533-390c9cc86586", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "dnd-character", - "name": "D&D Character", - "uuid": "eba5ba27-1c8b-485a-8bf4-08df4239a6f3", + "slug": "space-age", + "name": "Space Age", + "uuid": "dfb7c4aa-dc52-4973-8c50-f5153ab51406", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "pangram", - "name": "Pangram", - "uuid": "d319360a-afef-4b65-be5f-da45d48367cb", + "slug": "square-root", + "name": "Square Root", + "uuid": "aa031ed2-2e79-4956-8e31-9c86b971589a", "practices": [], "prerequisites": [], "difficulty": 2 }, { - "slug": "list-ops", - "name": "List Ops", - "uuid": "f5ade076-6afd-4f03-8916-543cb7f350a1", + "slug": "strain", + "name": "Strain", + "uuid": "fe975ff0-e374-44c9-910b-740cc3cff4ad", "practices": [], "prerequisites": [], "difficulty": 2 }, + { + "slug": "sum-of-multiples", + "name": "Sum of Multiples", + "uuid": "8f8697e6-2e8b-47dc-8bd0-747f29b93ae7", + "practices": [], + "prerequisites": [], + "difficulty": 2, + "topics": [ + "math" + ] + }, { "slug": "triangle", "name": "Triangle", @@ -382,17 +378,21 @@ "difficulty": 2 }, { - "slug": "binary-search", - "name": "Binary Search", - "uuid": "7177483a-8370-4d24-81c4-8dfdfd83846d", + "slug": "trinary", + "name": "Trinary", + "uuid": "db8c35d3-5203-4b3c-bb58-bd7a42ab2e5d", "practices": [], "prerequisites": [], - "difficulty": 2 + "difficulty": 2, + "status": "deprecated", + "topics": [ + "math" + ] }, { - "slug": "square-root", - "name": "Square Root", - "uuid": "aa031ed2-2e79-4956-8e31-9c86b971589a", + "slug": "two-fer", + "name": "Two-Fer", + "uuid": "b186e735-f638-4836-97c1-9c78c5e0078e", "practices": [], "prerequisites": [], "difficulty": 2 @@ -406,17 +406,17 @@ "difficulty": 2 }, { - "slug": "allergies", - "name": "Allergies", - "uuid": "68eec796-a269-4e66-84b5-e26574ff614e", + "slug": "all-your-base", + "name": "All Your Base", + "uuid": "b226abea-2da6-4af5-9a56-af1f21431130", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "all-your-base", - "name": "All Your Base", - "uuid": "b226abea-2da6-4af5-9a56-af1f21431130", + "slug": "allergies", + "name": "Allergies", + "uuid": "68eec796-a269-4e66-84b5-e26574ff614e", "practices": [], "prerequisites": [], "difficulty": 5 @@ -454,17 +454,17 @@ "difficulty": 5 }, { - "slug": "grade-school", - "name": "Grade School", - "uuid": "d9013304-cc50-4a56-a645-51c4a80f1c82", + "slug": "flower-field", + "name": "Flower Field", + "uuid": "0643257b-8e60-4d6f-9668-86173c24a77b", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "flower-field", - "name": "Flower Field", - "uuid": "0643257b-8e60-4d6f-9668-86173c24a77b", + "slug": "grade-school", + "name": "Grade School", + "uuid": "d9013304-cc50-4a56-a645-51c4a80f1c82", "practices": [], "prerequisites": [], "difficulty": 5 @@ -477,6 +477,14 @@ "prerequisites": [], "difficulty": 5 }, + { + "slug": "knapsack", + "name": "Knapsack", + "uuid": "5b7094ea-9702-41ca-b13b-c2100cda0bdc", + "practices": [], + "prerequisites": [], + "difficulty": 5 + }, { "slug": "largest-series-product", "name": "Largest Series Product", @@ -545,33 +553,33 @@ "difficulty": 5 }, { - "slug": "series", - "name": "Series", - "uuid": "f2ca089e-66db-4b85-8275-5932952a36bf", + "slug": "roman-numerals", + "name": "Roman Numerals", + "uuid": "461223ea-e86b-4b94-9e7a-ac3ec1aa8a12", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "word-count", - "name": "Word Count", - "uuid": "5fca0d45-2bf5-486e-9c57-25cff5e4a9c5", + "slug": "series", + "name": "Series", + "uuid": "f2ca089e-66db-4b85-8275-5932952a36bf", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "roman-numerals", - "name": "Roman Numerals", - "uuid": "461223ea-e86b-4b94-9e7a-ac3ec1aa8a12", + "slug": "sieve", + "name": "Sieve", + "uuid": "50f4505d-c82a-46a7-bfeb-0100c5f2d45f", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "sieve", - "name": "Sieve", - "uuid": "50f4505d-c82a-46a7-bfeb-0100c5f2d45f", + "slug": "word-count", + "name": "Word Count", + "uuid": "5fca0d45-2bf5-486e-9c57-25cff5e4a9c5", "practices": [], "prerequisites": [], "difficulty": 5 @@ -591,14 +599,6 @@ "practices": [], "prerequisites": [], "difficulty": 8 - }, - { - "slug": "knapsack", - "name": "Knapsack", - "uuid": "5b7094ea-9702-41ca-b13b-c2100cda0bdc", - "practices": [], - "prerequisites": [], - "difficulty": 5 } ] },