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
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')
Comments
Leave a comment