There are 10 characters, and each string is 100 characters long. Please write a program in any language to find the longest string that all 10 strings contain.

topic description

there are 10 characters, and each string is 100 characters long. Please write a program in any language to find the longest string that all 10 strings contain.

Sep.08,2021

Peking University has a topic. Except that the data are basically the same, you can take a look at http://poj.org/problem?id=3080

.

title means to input no more than ten strings, each with a length of no more than 60, and then find out the longest common substring. If there are several substrings of the same length, output the smallest one in dictionary order. If the length of the common substring is less than 3, it will not output (because it is DNA)
you can modify

according to the following program.
str_1 =  "1234567890"
str_2 =  "1235486332"
str_3 =  "1234567890"
str_4 =  "1234567890"
str_5 =  "1234567890"
str_6 =  "1234567890"
str_7 =  "1234567890"
str_8 =  "1234567890"
str_9 =  "1234567890"
str_10 = "1234567890"

res = []

daiding = set()
for i in range(10):
    str_1_1 = str_1[i]
    str_2_1 = str_2[i]
    str_3_1 = str_3[i]
    str_4_1 = str_4[i]
    str_5_1 = str_5[i]
    str_6_1 = str_6[i]
    str_7_1 = str_7[i]
    str_8_1 = str_8[i]
    str_9_1 = str_9[i]
    str_10_1 = str_10[i]
    daiding.add(str_1_1)
    daiding.add(str_2_1)
    daiding.add(str_3_1)
    daiding.add(str_4_1)
    daiding.add(str_5_1)
    daiding.add(str_6_1)
    daiding.add(str_7_1)
    daiding.add(str_8_1)
    daiding.add(str_9_1)
    daiding.add(str_10_1)

    if daiding.__len__() ==1:
        res.append(str_1_1)
    daiding.clear()

print(res)
Menu