Click here to Skip to main content
15,747,059 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Build a Python program to simulate a liquid flow through a modeled material which is a square matrix with random integers of 0-9.
(1) The liquid should start from the top left corner of the matrix.
(2) It could move towards right, left or below adjacent matrix. Lower value matrix has higher potential. When it starts from the top left corner, it can travel to the right or bottom.
(3) In the case of the adjacent matrix (left, right or/and below) have the same value, the program should be able to simulate all conditions. The program should be able to
simulate all possibilities of the liquid movement.
(4) The liquid cannot move back to the same path from where it flows. This means that if the liquid moves from left to right, it can only travel to bottom or right again. Let’s say the liquid moves bottom, now it can move either to the left, right or bottom depending on the values of the integers.
(5) The movement of the liquid is considered stop at the below edge (final row) of the matrix only.
(6) In case the liquid reaches the left/right edge of the matrix it should move downwards and choose its path again, either to the right/left or bottom. (It flows to the lower integer)
(7) The program should be able to show the sum of all numbers that the liquid
has pass through, in all possibilities and visualize the path.

What I have tried:

We have not tried anything so far, it would be really nice if you could help us
Updated 11-Aug-20 3:29am

I guess you're going to have to write code to
1) define a matrix
2) load the matrix ? from a file
3) traverse the matrix according to your rules recording the result
4) output the result/sum as per step 7

If you break things down into small, manageable 'chunks', and be able to test each one as you go forward, it should be simple enough..

I'd add an extra step 'somewhere' - display matrix and current position - so you can debug your progress
Share this answer
Yasvinraj 11-Aug-20 8:54am    
I really appreciate your explanation but i am in need for the code right now.
Garth J Lancaster 11-Aug-20 9:01am    
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. And if you hand in work that we produce, you are a liar and a fool - your tutor can also see this site !!!!

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Share this answer
We have not tried anything so far

As programmer, your job is to sort out the requirement to deduce logical organization.
The second step is to take a sheet of paper and a pencil and try to solve the problem, and refine your procedure until it work.
The procedure is your algorithm, then you have to translate to code.
The algorithm don't comes by magic, it is a trial and error search, that is how you learn.
i am in need for the code right now.

For this kind of help, you should think about hiring a professional programmer as this is a job that you don't tell.
Note that just giving you the code is basically defeating the purpose of homework.
Build a Python program to simulate a liquid flow through a modeled material which is a square matrix

The rules in requirement are anything but liquid behavior. This liquid don't act as a liquid.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900