Untitled

 avatar
unknown
python
2 years ago
621 B
6
Indexable
s = input()
strings = []  
while True:
    
    tmp = input().strip()
    if tmp:
        strings.append(tmp)
    else:
        break


lengths = []

for line in strings:
    start_index = None
    end_index = None
    min_len = float('inf')
    for i, c in enumerate(line):
        if c in s and start_index is None:
            start_index = i
        elif c in s:
            if min_len > i - start_index:
                min_len = i - start_index
            start_index = i
    if min_len != float('inf') and min_len != 0:
        lengths.append(min_len + 1)
print(", ".join([str(i) for i in sorted(set(lengths))]))
Editor is loading...