Aquarium stocking report
EasyOnline Assessment
Produce the stocking report of a fish store's display tanks using the "one inch of adult fish per gallon" rule of thumb.
A tank's usable volume is 90% of its labelled gallons, because gravel and decorations take up the rest. Its load is the sum, over all fish in it, of count * adultInches. Its stocking level is load / usable volume.
tanks has entries "<tank> <gallons>" (tank names are unique). species has entries "<species> <adultInches> <minSchool>": schooling fish need at least minSchool of their species in the same tank (1 means no requirement). fish has entries "<tank> <species> <count>"; the same tank and species may appear on several lines, and then the counts add up.
For every tank produce a line "<tank> <pct>% <status>":
pctis the stocking level as a percentage rounded to the nearest whole number, with exact halves rounded up.statusisokif the stocking level is at most 80%,fullif it is above 80% but at most 100%, andoverabove 100%. Decide the status from the exact level, not from the roundedpct.- If any species in the tank has a total count below its
minSchool, append a space andschool:followed by those species names in alphabetical order separated by commas (no spaces), e.g."reef 71% ok school:cory,neon". A species with a total count of zero is not in the tank.
Tanks with no fish read 0% ok.
Input: tanks, species, fish. Every fish line names a listed tank and species.
Output: the list of lines, ordered by exact stocking level from highest to lowest, with tanks at the same level ordered by tank name in ordinary string order.
Example 1
- Input:
- [["reef 20","nano 5","cichlid 55"],["neon 1 6","cory 3 4","betta 3 1","oscar 12 1","guppy 2 3","tetra 2 5"],["reef neon 6","reef cory 4","reef betta 1","nano betta 1","nano neon 3","cichlid oscar 3","cichlid cory 2","cichlid cory 1"]]
- Output:
- ["nano 133% over school:neon","reef 117% over","cichlid 91% full school:cory"]
- Explanation
reef(20 gal, 18 usable) holds 6 neon, 4 cory and 1 betta: load 6 + 12 + 3 = 21, level 116.7%, so117% over; both schools meet their minimums.nano(4.5 usable) has load 3 + 3 = 6, level 133.3%, and only 3 neon against a minimum of 6, so133% over school:neon.cichlid(49.5 usable) has load 36 + 9 = 45, level 90.9%,91% full; its two cory lines add up to 3, below 4. Sorted by level: nano, reef, cichlid.
Example 2
- Input:
- [["a 1000","z 1000","q 16","empty 10"],["neon 1 6","cory 3 4","betta 3 1","oscar 12 1","guppy 2 3","tetra 2 5"],["a betta 1","a oscar 1","a oscar 59","z oscar 60","z cory 3","z cory 3","q cory 3"]]
- Output:
- ["z 82% full","a 80% full","q 63% ok school:cory","empty 0% ok"]
- Explanation
ahas load 3 + 12 + 708 = 723 on 900 usable: 80.33%, which prints as80%but is above 80%, so it isfull, notok.zhas 720 + 18 = 738 (its two cory lines add to 6, enough):82% full.q(14.4 usable) has load 9: exactly 62.5%, rounded up to 63, with 3 cory below the minimum of 4.emptyis0% ok. Order: z, a, q, empty.
Example 3
- Input:
- [["dock 16","cove 16"],["neon 1 6","cory 3 4","betta 3 1","oscar 12 1","guppy 2 3","tetra 2 5"],["dock cory 3","dock neon 0","cove cory 4"]]
- Output:
- ["cove 83% full","dock 63% ok school:cory"]
- Explanation
dockhas load 9 on 14.4 usable: 62.5% rounds up to63%, and its 3 cory are below the minimum of 4 (the 0 neon line adds no fish).covehas 4 cory (enough): load 12, 83.3%,83% full. The higher level comes first.
Constraints
1 <= tanks.length <= 30; gallons are integers from1to5,000; tank names are unique lowercase-and-digit strings1 <= species.length <= 30;adultInchesis from1to60,minSchoolfrom1to200 <= fish.length <= 500; eachcountis an integer from0to500; every tank and species named is listed