What will I learn?
Using recursive functions on a large 2 dimensional grid, you implement flood filling algorithm and have to improve the performance of your code using memoization.
External resources
Multidimensional arrayRecursionFlood fillMemoizationLearning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
The goal of this puzzle is to find in a grid the list of adjacents cells that are from the same type (water or ground) and compute the size of the surface. The complexity of the problem is related to the size of the grid and the need to optimize the number of iteration. You will also have to count cells only once during your traversal.
A higher resolution is required to access the IDE
Story
Did you know that the distance between your thumb and your little finger is roughly 20cm? Quite useful to evaluate distances, don't you think? Speaking of evaluating distances, take out your geometry tools, because you will have to measure and compare surface areas with this puzzle.