algo - light illumination value mapping
Consider this board map : we have a board of m x n size, there are light bulbs with varying power installed in different cells on the map, 1 light bulb only per cell. if a bulb has power index of 10, then a cell whose shortest distance from the bulb is 4 cells away will receive 10 - 4 = 6 illumination index from the bulb.
for example, look at this initial stage
a light bulb with 7 illumination index is located in row 2 col 2 will illuminate cell in row 1 col 4 at 3 illumination index. if a cell receives illumination from multiple light bulbs, the one with highest illumination index wins.
for this board, the final state will look like this: final state
another example of a light bulb with illumination power of 10 placed at the center of the map example once the illumination power hits 0, no adjacent cell will be illuminated.
what I have in mind is to check each non-lightbulb cell on the board against each light bulb to determine the final illumination point on that cell. Is there a better way to solve this problem?
Comments
Post a Comment