Explore Westonci.ca, the top Q&A platform where your questions are answered by professionals and enthusiasts alike. Get detailed and precise answers to your questions from a dedicated community of experts on our Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
Sagot :
Using the code in python we write a code to determine the prison bars and not let the prisoner escape.
How to define list in Python?
In Python, a list is represented as a sequence of objects separated by commas and enclosed in square brackets [], so an empty list, for example, can be represented by square brackets with no content.
So in an easier way we have that the code, need have vertical bars that are spaced one unit apart and determine the area of the largest hole, so:
def largestArea(N, M, H,
V, h, v):
s1 = set([]);
s2 = set([]);
for i in range(1, N + 2):
s1.add(i);
for i in range(1, M + 2):
s2.add(i);
for i in range(h):
s1.remove(H[i]);
for i in range( v ):
s2.remove(V[i]);
list1 = [0] * len(s1)
list2 = [0]*len(s2);
i = 0;
for it1 in s1:
list1[i] = it1;
i += 1
i = 0;
for it2 in s2:
list2[i] = it2
i += 1
list1.sort();
list2.sort();
maxH = 0
p1 = 0
maxV = 0
p2 = 0;
for j in range(len(s1)):
maxH = max(maxH, list1[j] - p1);
p1 = list1[j];
for j in range(len(s2)):
maxV = max(maxV, list2[j] - p2);
p2 = list2[j];
print((maxV * maxH))
if __name__ == "__main__":
N = 3
M = 3;
H = [2]
V = [2];
h = len(H)
v = len(V);
largestArea(N, M, H, V, h, v);
See more about python at brainly.com/question/19705654
Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Your questions are important to us at Westonci.ca. Visit again for expert answers and reliable information.