Menu
CoddyTech

Data Transformer

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 78 of 78.

challenge icon

Challenge

Hard

Turn 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,History

A 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,History

the output is:

Qualified students: 2
S123: 88.33
S125: 90.67
Subjects:
Math: 2
Science: 1
History: 2
Physics: 1

S124 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

Practice on your own: Online GDScript compiler