import random
def print_longest_consecutive_zeros(k, l):
# Create an array to store the binary string
binary_string = [0] * l
# Place k ones in the array at random positions
for _ in range(k):
random_position = random.randint(0, l - 1)
# Ensure the random position is not already occupied
while binary_string[random_position] == 1:
random_position = random.randint(0, l - 1)
binary_string[random_position] = 1
# Convert the array to a string
binary_string = ''.join(map(str, binary_string))
# Calculate the length of the longest consecutive zeros
max_zeros = 0
current_zeros = 0
for char in binary_string:
if char == '0':
current_zeros += 1
if current_zeros > max_zeros:
max_zeros = current_zeros
else:
current_zeros = 0
# Print the result
print(f"Length of the longest consecutive zeros: {max_zeros}")
if __name__ == "__main__":
# Get input for the number of ones (k) and length of binary string (l)
k = int(input("Enter the number of ones (k): "))
l = int(input("Enter the length of binary string (l): "))
# Call the function to print the result
print_longest_consecutive_zeros(k, l)