← Questions

Pour water onto a terrain

0
AirbnbCodingLast asked Feb 2026

An array gives the height of each column of a terrain.

  1. Print the terrain.
  2. Drop a given number of water units at a column, one at a time. Each unit moves left if it can eventually fall lower that way, else right, else it stays where it is and raises the level there. Print the terrain with the water.

Make the movement rules exact before coding, and keep the printing code separate from the simulation.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding