02. Programming Fundamentals Final Exam - 3. Plant Discovery:
Някой да е решил за 100/100 тази задача? Мисля че проблема за мен идва от тези проверки за всяка команда. Note: If any of the command is invalid, print "error"
Решението ми: за 50/100
https://pastebin.com/kbCH4tDR
Programming Fundamentals Final Exam 09.08.2020
Problem 3. Plant Discovery
On the first line you will receive a number n. On the next n lines, you will be given some information about the plants that you have discovered in the format: "{plant}<->{rarity}". Store that information, because you will need it later. If you receive a plant more than once, update its rarity. Check properties.
After that until you receive the command "Exhibition" you will be given some of these commands:
- Rate: {plant} - {rating} – add the given rating to the plant (store all ratings)
- Update: {plant} - {new_rarity} – update the rarity of the plant with the new one
- Reset: {plant} – remove all the ratings of the given plant
Note: If any of the command is invalid, print "error"
After the command "Exhibition" print the information that you have about the plants in the following format:
Plants for the exhibition:
- {plant_name}; Rarity: {rarity}; Rating: {average_rating formatted to the 2nd digit}
…
The plants should be sorted by rarity descending, then by average rating descending
Input |
Output |
3 Arnoldii<->4 Woodii<->7 Welwitschia<->2 Rate: Woodii - 10 Rate: Welwitschia - 7 Rate: Arnoldii - 3 Rate: Woodii - 5 Update: Woodii - 5 Reset: Arnoldii Exhibition |
Plants for the exhibition: - Woodii; Rarity: 5; Rating: 7.50 - Arnoldii; Rarity: 4; Rating: 0.00 - Welwitschia; Rarity: 2; Rating: 7.00 |
2 Candelabra<->10 Oahu<->10 Rate: Oahu - 7 Rate: Candelabra - 6 Exhibition |
Plants for the exhibition: - Oahu; Rarity: 10; Rating: 7.00 - Candelabra; Rarity: 10; Rating: 6.00 |
Благодаря за кода и най-вече за обяснението! :)
Много полезно обяснение.