diff --git a/bin/clean_topics_vs_practices.py b/bin/clean_topics_vs_practices.py new file mode 100755 index 000000000..ed3b55d01 --- /dev/null +++ b/bin/clean_topics_vs_practices.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +import json + + +def main(): + with open("config.json", encoding="utf-8") as f: + config = json.load(f) + + concepts = {c['slug'] for c in config['concepts']} + + for practice_exercise in config['exercises']['practice']: + if practice_exercise['topics'] is None: + continue + + practice_exercise['practices'].extend((topic for topic in practice_exercise['topics'] if topic in concepts)) + practice_exercise['topics'] = [topic for topic in practice_exercise['topics'] if topic not in concepts] + + for concept in concepts: + count = 0 + for practice_exercise in config['exercises']['practice']: + if concept in practice_exercise['practices']: + count += 1 + if count > 10: + practice_exercise['practices'].remove(concept) + practice_exercise['topics'].append(concept) + + for practice_exercise in config['exercises']['practice']: + practice_exercise['practices'].sort() + + if practice_exercise['topics'] is not None: + practice_exercise['topics'].sort() + + + with open("config.json", 'w', encoding="utf-8") as f: + json.dump(config, f, indent=2, ensure_ascii=False) + f.write('\n') + + print("Updated config.json") + + +if __name__ == '__main__': + main() diff --git a/config.json b/config.json index 6c5876d6b..6707e7bde 100644 --- a/config.json +++ b/config.json @@ -192,11 +192,12 @@ "slug": "hello-world", "name": "Hello World", "uuid": "13ec1ebe-d71b-436f-ab12-25305e814171", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 1, "topics": [ - "strings", "test_driven_development" ] }, @@ -204,13 +205,14 @@ "slug": "reverse-string", "name": "Reverse String", "uuid": "ecf8d1e3-9400-4d1a-8326-2e2820bce024", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 1, "topics": [ "iterators", - "str_vs_string", - "strings" + "str_vs_string" ] }, { @@ -228,12 +230,13 @@ "slug": "clock", "name": "Clock", "uuid": "543a3ca2-fb9b-4f20-a873-ff23595d41df", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "derive", - "structs", "traits" ] }, @@ -241,15 +244,16 @@ "slug": "anagram", "name": "Anagram", "uuid": "f3172997-91f5-4941-a76e-91c4b8eed401", - "practices": [], + "practices": [ + "loops", + "strings" + ], "prerequisites": [], "difficulty": 4, "topics": [ "iterators", "lifetimes", - "loops", "str_vs_string", - "strings", "vectors" ] }, @@ -270,11 +274,12 @@ "slug": "sublist", "name": "Sublist", "uuid": "644ffd17-548e-4405-bfd5-a58df74cc19d", - "practices": [], + "practices": [ + "enums" + ], "prerequisites": [], "difficulty": 7, "topics": [ - "enums", "generic_over_type" ] }, @@ -330,15 +335,16 @@ "slug": "poker", "name": "Poker", "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977", - "practices": [], + "practices": [ + "enums", + "strings", + "structs" + ], "prerequisites": [], "difficulty": 10, "topics": [ - "enums", "lifetimes", "parsing", - "strings", - "structs", "traits" ] }, @@ -368,13 +374,14 @@ "slug": "beer-song", "name": "Beer Song", "uuid": "bb42bc3a-139d-4cab-8b3a-2eac2e1b77b6", - "practices": [], + "practices": [ + "loops", + "strings" + ], "prerequisites": [], "difficulty": 1, "topics": [ "case", - "loops", - "strings", "vectors" ] }, @@ -382,11 +389,12 @@ "slug": "difference-of-squares", "name": "Difference Of Squares", "uuid": "aee49878-f727-400b-8fb5-eaf83447cf87", - "practices": [], + "practices": [ + "fold" + ], "prerequisites": [], "difficulty": 1, "topics": [ - "fold", "map", "math" ] @@ -406,11 +414,12 @@ "slug": "leap", "name": "Leap", "uuid": "ef52f576-9c33-4cc1-a018-803ace8897f6", - "practices": [], + "practices": [ + "booleans" + ], "prerequisites": [], "difficulty": 1, "topics": [ - "booleans", "conditionals" ] }, @@ -418,11 +427,12 @@ "slug": "nth-prime", "name": "Nth Prime", "uuid": "ee5048a7-c625-434d-a0a2-4fd54757ee02", - "practices": [], + "practices": [ + "loops" + ], "prerequisites": [], "difficulty": 1, "topics": [ - "loops", "math", "primes" ] @@ -453,12 +463,13 @@ "slug": "raindrops", "name": "Raindrops", "uuid": "2c12be9b-3a02-4161-8eac-050642ad791f", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 1, "topics": [ "conditionals", - "strings", "type_conversion", "variables" ] @@ -480,12 +491,13 @@ "slug": "bob", "name": "Bob", "uuid": "38ef1802-2730-4f94-bafe-d2cd6b3e7f95", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 1, "topics": [ - "chars", - "strings" + "chars" ] }, { @@ -516,13 +528,14 @@ "slug": "acronym", "name": "Acronym", "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9", - "practices": [], + "practices": [ + "loops" + ], "prerequisites": [], "difficulty": 4, "topics": [ "filter", "flat_map", - "loops", "map", "vectors" ] @@ -531,12 +544,13 @@ "slug": "all-your-base", "name": "All Your Base", "uuid": "54c11dae-3878-4bec-b8d6-775b7d4f317b", - "practices": [], + "practices": [ + "fold" + ], "prerequisites": [], "difficulty": 4, "topics": [ "enumerate", - "fold", "map", "math", "result_type" @@ -546,14 +560,15 @@ "slug": "allergies", "name": "Allergies", "uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d", - "practices": [], + "practices": [ + "enums", + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "bitwise", - "enums", "filter", - "structs", "vectors" ] }, @@ -561,14 +576,15 @@ "slug": "alphametics", "name": "Alphametics", "uuid": "7450bd80-2388-42ac-a61f-097e82581475", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 4, "topics": [ "combinations", "external_crates", - "parsing", - "strings" + "parsing" ] }, { @@ -588,27 +604,29 @@ "slug": "bowling", "name": "Bowling", "uuid": "fec447a5-cf11-4ddd-b0fd-63bcc4e245cd", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "goofy_bowling_logic", - "result_type", - "structs" + "result_type" ] }, { "slug": "dot-dsl", "name": "Dot Dsl", "uuid": "7bc60899-3b12-4c51-b23b-8dced5845e4c", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "builder_pattern", "derive", - "modules", - "structs" + "modules" ] }, { @@ -626,13 +644,14 @@ "slug": "grade-school", "name": "Grade School", "uuid": "5ca03812-c229-48db-b7fd-0889b22f8d1d", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "entry_api", "option_type", - "structs", "vectors" ] }, @@ -651,39 +670,42 @@ "slug": "isbn-verifier", "name": "Isbn Verifier", "uuid": "c986c240-46de-419c-8ed6-700eb68f8db6", - "practices": [], + "practices": [ + "loops" + ], "prerequisites": [], "difficulty": 4, "topics": [ - "int_string_conversion", - "loops" + "int_string_conversion" ] }, { "slug": "isogram", "name": "Isogram", "uuid": "d141ec66-a161-4c3d-832b-439699bf0d4c", - "practices": [], + "practices": [ + "strings" + ], "prerequisites": [], "difficulty": 4, "topics": [ "chars", - "iterators", - "strings" + "iterators" ] }, { "slug": "nucleotide-count", "name": "Nucleotide Count", "uuid": "3f54853b-cc65-4282-ab25-8dc3fdf43c03", - "practices": [], + "practices": [ + "mutability" + ], "prerequisites": [], "difficulty": 4, "topics": [ "entry_api", "filter", "match", - "mutability", "result_type" ] }, @@ -703,14 +725,15 @@ "slug": "palindrome-products", "name": "Palindrome Products", "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", - "practices": [], + "practices": [ + "strings", + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "calculation", - "math", - "strings", - "structs" + "math" ] }, { @@ -766,12 +789,13 @@ "slug": "queen-attack", "name": "Queen Attack", "uuid": "30c33e3d-8034-4618-8346-2ae906961579", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "result_type", - "structs", "traits" ] }, @@ -779,28 +803,30 @@ "slug": "rna-transcription", "name": "Rna Transcription", "uuid": "9a219d87-cd32-4e12-a879-bfb5747c2369", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "match", "result_type", "str_vs_string", - "strings", - "structs" + "strings" ] }, { "slug": "run-length-encoding", "name": "Run Length Encoding", "uuid": "4dc9b165-792a-4438-be80-df9aab6f6a9c", - "practices": [], + "practices": [ + "loops" + ], "prerequisites": [], "difficulty": 4, "topics": [ "chars", "int_string_conversion", - "loops", "strings" ] }, @@ -858,12 +884,13 @@ "slug": "simple-linked-list", "name": "Simple Linked List", "uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237", - "practices": [], + "practices": [ + "structs" + ], "prerequisites": [], "difficulty": 4, "topics": [ "lists", - "structs", "type_conversion" ] }, @@ -883,11 +910,12 @@ "slug": "tournament", "name": "Tournament", "uuid": "9a2406cc-5037-4761-b820-bb25b1d397c8", - "practices": [], + "practices": [ + "enums" + ], "prerequisites": [], "difficulty": 4, "topics": [ - "enums", "hashmaps", "sorting", "structs" @@ -908,12 +936,13 @@ "slug": "two-bucket", "name": "Two Bucket", "uuid": "1850fb3f-9dad-449a-90b6-9d90038cf34d", - "practices": [], + "practices": [ + "loops" + ], "prerequisites": [], "difficulty": 4, "topics": [ - "algorithms", - "loops" + "algorithms" ] }, { @@ -934,11 +963,12 @@ "slug": "robot-simulator", "name": "Robot Simulator", "uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66", - "practices": [], + "practices": [ + "enums" + ], "prerequisites": [], "difficulty": 7, "topics": [ - "enums", "immutability" ] }, @@ -946,12 +976,13 @@ "slug": "robot-name", "name": "Robot Name", "uuid": "ec7f66c2-749e-4d00-9c11-fa9d106632e4", - "practices": [], + "practices": [ + "mutability" + ], "prerequisites": [], "difficulty": 4, "topics": [ "lifetimes", - "mutability", "randomness", "slices", "structs" @@ -1041,12 +1072,13 @@ "slug": "rectangles", "name": "Rectangles", "uuid": "cc4ccd99-1c97-4ee7-890c-d629b4e1e46d", - "practices": [], + "practices": [ + "enums" + ], "prerequisites": [], "difficulty": 10, "topics": [ "algorithms", - "enums", "structs", "traits" ] @@ -1237,12 +1269,13 @@ "slug": "roman-numerals", "name": "Roman Numerals", "uuid": "498be645-734a-49b7-aba7-aae1e051e1f0", - "practices": [], + "practices": [ + "loops", + "mutability" + ], "prerequisites": [], "difficulty": 4, "topics": [ - "loops", - "mutability", "result_type", "structs", "traits" @@ -1380,11 +1413,12 @@ "slug": "scale-generator", "name": "Scale Generator", "uuid": "b9436a89-90cb-4fb7-95b0-758f17c309ff", - "practices": [], + "practices": [ + "enums" + ], "prerequisites": [], "difficulty": 7, "topics": [ - "enums", "from_primitive", "music_theory", "to_primitive",