43 lines
1.0 KiB
Python
Executable File
43 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
def get_repeated_int(str1, str2):
|
|
count = 0
|
|
for i in range(len(str1)):
|
|
if str2[i] == str1[i]:
|
|
count += 1
|
|
return count
|
|
|
|
|
|
def get_repeated_str(str1, str2):
|
|
out = ""
|
|
for i in range(len(str1)):
|
|
if str2[i] == str1[i]:
|
|
out += str1[i]
|
|
return out
|
|
|
|
|
|
if __name__ == '__main__':
|
|
inputs = []
|
|
|
|
with open("input.txt") as fp:
|
|
line = fp.readline()
|
|
while line:
|
|
inputs.append(line.strip())
|
|
line = fp.readline()
|
|
|
|
max_repeated = 0
|
|
max_ids = []
|
|
|
|
for idx1, val1 in enumerate(inputs):
|
|
for idx2, val2 in enumerate(inputs):
|
|
if idx1 != idx2:
|
|
repeated = get_repeated_int(val1, val2)
|
|
if repeated > max_repeated:
|
|
max_repeated = repeated
|
|
max_ids.clear()
|
|
max_ids.append(idx1)
|
|
max_ids.append(idx2)
|
|
|
|
print(get_repeated_str(inputs[max_ids[0]], inputs[max_ids[1]]))
|