You have cultivated a plant, and after three long months, the time has come to reap the fruits (or the flowers, in this case) of your hard work. During the growth phase, you added water and fertilizer, and kept a constant temperature. It's time to check how much the plant has grown!
A plant is represented horizontally, from the base to the left, to the end to the right:
---@---@---@
The stem is made of hyphens, and the flowers are represented by symbols. A plant always starts with the stem, and always ends with flowers.
The four given parameters are:
seed (string) determines the type of flowers generated by the plant.water (integer) each unit of water extends the portion of stem between the flowers, and gives the total number of segments (stem + flowers) of the plant.fert (integer) each unit of fertilizer increases the amount of flowers, grouped in clusters.temp (integer) if the temperature recorded is between 20°C and 30°C (bounds included) the plant grows normally, otherwise all the flowers die, except for a single survivor at the end of the stem.Given the above parameters, implement a function that returns a string representing the plant (see the examples below for a better visualization).
plant("@", 3, 3, 25) ➞ "---@@@---@@@---@@@"
// Water gives the length of the stem portions between flowers.
// Water gives the total number of segments.
// Fertilizer gives the length of flowers clusters.
// In this case the temperature is in the acceptable range 20°C | 30°C
plant("#", 1, 5, 30) ➞ "-#####"
plant("&", 5, 1, 20) ➞ "-----&-----&-----&-----&-----&"
plant("§", 3, 3, 15) ➞ "---------§"
// The temperature out of range make all flowers die, except the last one.
// The stem is not affected by temperature.
All given cases will have valid parameters for water and fert, you have to only check that temp is in the "safe" range (20°C|30°C).