Answer to Question #277721 in Python for maiden

Question #277721

Create a python program for physics and materials science. In physics, chemistry, and materials science, percolation refers to the movement and filtering of fluids through porous materials. (Wikipedia.org). Consider a simplified model below. Imagine, this is a filter or maybe some layers of stones such that when a certain amount of fluid is put on top, it will reach the bottom only if there is a direct passage. In this case, the blue squares serve as the porous materials or the holes where fluid may pass. Your task is to simulate this simple percolation by representing them in a 2-dimensional array. The input would be in a string, while the output would either be yes or no to indicate whether the fluid can pass through the filter or not.


Note: It should also work with these two inputs:

1. “1” -> Yes

2. “0” -> No


Examples:

Input: “1,0,0,0,0;0,1,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,1,0”

Output: Yes


Input: “0,0,0,1,0;0,1,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,1,0”

Output: No


1
Expert's answer
2021-12-10T00:36:34-0500
sample_size = int(input('Enter integer here: '))
list1 = []
for i in range(sample_size):
    sample = int(input('Enter 1 or 0: '))
    list1.append(sample)
if list1[0] == 1:
    print('yes')
else:
    print('no')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS