Skip to content

mrcblyn/water_overflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Water Overflow Coding Challenge

Repository submission for the Water Overflow Coding Challenge. Built primarily using Python (Flask), basic HTML, and Docker.

Submitted by: Maricia Balayan (mariciabalayan@gmail.com)

Problem Statement

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 jth glass of the ith row when K litres are poured into the top most glass.

Assumptions

  • 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: image

  • Input is always i (row), j (column) and K (number of liters), where:

    • i (row) is always a valid non-negative integer
    • j (column) is always a valid non-negative integer
    • K (number of liters) is always a valid non-negative number
  • Only the jth glass of the ith row is needed in the output

Limitations

  • 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

Dependencies

  • Docker and docker-compose must be installed
  • Python modules used have been added as part of the requirements to be installed by Docker.

Executing the program

  • 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 image
  • Open the application in http://localhost:5000 image
  • Input all fields and submit to view the output image

Testing

  • Tests have been created and ran using pytest: image

About

Repository for the Water Overflow Coding Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published