Data Transformer
Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 78 of 78.
Challenge
HardTurn student records into a report. The program reads a whole number n, then n records. A record has three fields separated by ;: a student id, the grades (whole numbers separated by commas) and the subjects (separated by commas):
S123;88,92,85;Math,Science,HistoryA student is qualified when every grade is above 70 (a grade of exactly 70 does not qualify). Check it with the array method all().
Print Qualified students: and how many there are. Then, for each qualified student in input order, print the id, : and the average of the grades with two decimals. Then print Subjects: and, for each subject taken by at least one qualified student, the subject, : and how many qualified students take it, in the order the subjects first appear.
For these inputs:
3
S123;88,92,85;Math,Science,History
S124;65,95,80;Math,Science,English
S125;91,89,92;Math,Physics,Historythe output is:
Qualified students: 2
S123: 88.33
S125: 90.67
Subjects:
Math: 2
Science: 1
History: 2
Physics: 1S124 is not qualified because of the grade 65, so English is not counted. With no qualified students, the output ends with the line Subjects:.
Try it yourself
extends Node
func _ready():
var n := int(OS.read_string_from_stdin())
# Read n records, then print the qualified students and the subjects
pass
All lessons in Logic & Flow
1Strings In Depth
String MethodsSearching in StringsReplace and TrimSplit and JoinRecap - Username Check4Dictionaries Part 2
Nested DictionariesArrays of DictionariesMerging DictionariesCopying DictionariesRecap - Frequency Counter2Advanced Decision Making
Match With VariablesMatch GuardsArray PatternsDictionary PatternsMembership ChecksRecap - Command Parser5Contact Book Application
Display MenuAdd Contact8Student Records Manager
Project OverviewAdd Student3Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysJagged ArraysCommon 2D Array PatternsRecap - Game Board6Sets with Dictionaries
What is a Set?Dictionary as a SetAdding and RemovingUnion and IntersectionSet DifferenceRecap - Remove Duplicates9Advanced Data Aggregation
Summing ValuesFinding Minimum and MaximumCustom SortingRecap - Dictionary SorterPractice on your own: Online GDScript compiler