Repository submission for the Water Overflow Coding Challenge. Built primarily using Python (Flask), basic HTML, and Docker.
Submitted by: Maricia Balayan (mariciabalayan@gmail.com)
There is a stack of water glasses in a form of triangle. Each glass has a 250ml capacity. When a liquid is poured into the top most glass any overflow is evenly distributed between the glasses in the next row. That is, half of the overflow pours into the left glass while the remainder of the overflow pours into the right glass.
Write a program that is able to calculate and illustrate how much liquid is in the j
th glass of the i
th row when K
litres are poured into the top most glass.
-
A diagram has been provided in the project specifications, which seems to have an error in the last row. I have assumed that the values highlighted in red should be replaced by the values in green:
-
Input is always
i
(row),j
(column) andK
(number of liters), where:i
(row) is always a valid non-negative integerj
(column) is always a valid non-negative integerK
(number of liters) is always a valid non-negative number
-
Only the
j
th glass of thei
th row is needed in the output
- The solution does not handle invalid inputs, assumes always valid
- The solution may not work for very large inputs
- The output illustration may break for very large outputs
- The solution and illustration only take into account glasses until the specified row
- Docker and docker-compose must be installed
- Python modules used have been added as part of the requirements to be installed by Docker.
- Clone the repository
git clone https://github.com/mrcblyn/water_overflow.git
- Change directory into water_overflow
cd water_overflow
- Start Docker
- Run
docker-compose up
- Open the application in http://localhost:5000
- Input all fields and submit to view the output