from __builtins__ import * import utils # Places sunflowers at random locations in the specified area. # # We cannot simply just use utils.plant_grid here, because we need to also keep track # of the number of petals on each sunflower, and return a dictionary mapping petal count # to a list of sunflower coordinates containing that petal count. # # Parameters: # width (int): The number of columns in the grid. # height (int): The number of rows in the grid. # # Returns: # dictionary: A dictionary mapping petal count to a list of sunflower coordinates containing that petal count. # # Important: # utils.plant_grid uses very similar logic with this function, so any changes to this function should be reflected in utils.plant_grid as well. def place(width, height): return utils.plant_grid_return_measurements(width, height, [Entities.Sunflower], 0.75, True) # Harvests all sunflowers in the specified area. # # The rules for sunflower harvesting is that we must harvest the flowers with the most petals first # as doing so gives us an 8x bonus. # # Parameters: # width (int): The number of columns in the grid. # height (int): The number of rows in the grid. # flowers (dictionary): A dictionary mapping petal count to a list of sunflower coordinates containing that petal count. def harvest_grid(width, height, flowers): result = {} # in reverse order of petals petals = [15, 14, 13, 12, 11, 10, 9, 8, 7] for count in petals: for coord in flowers[count]: utils.move_to(coord[0], coord[1]) harvest()