09. Auto-Engineering Company
Здравейте!
Някой може ли да помогне с тази задача? Не съм сигурен как да премахна повтарящия се модел и да сумирам числата.
Задачата:
You are tasked to create a register for a company that produces cars. You need to store how many cars have been produced from a specified model of a specified brand.
Input
The input comes as array of strings. Each element holds information in the following format:
“{carBrand} | {carModel} | {producedCars}”
The car brands and models are strings, the produced cars are numbers. If the car brand you’ve received already exists, just add the new car model to it with the produced cars as its value. If even the car model exists, just add the given value to the current one.
Output
As output you need to print - for every car brand, the car models, and number of cars produced from that model. The output format is:
“{carBrand}
###{carModel} -> {producedCars}
###{carModel2} -> {producedCars}
...”
The order of printing is the order in which the brands and models first appear in the input. The first brand in the input should be the first printed and so on. For each brand, the first model received from that brand, should be the first printed and so on.
линк към Judge:
https://judge.softuni.bg/Contests/Compete/Index/2769#8
Моя код:
https://pastebin.com/VW8gHFnQ
мерси много предварително за помоща и насоките.