题解 | #查找兄弟单词#
查找兄弟单词
http://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
python3解法
string = input().split()
l1 = string[1:-2]
l2 = string[-2]
k = int(string[-1])-1
def is_brother(a, b):
if len(a) == len(b) and a != b:
counts = 0
for i in a:
if a.count(i)==b.count(i):
counts = counts +1
if counts == len(a):
return True
else:
return False
res = []
for i in l1:
if is_brother(i, l2):
res.append(i)
print(len(res))
res.sort(key=lambda c: c.lower())
if len(res) > k:
print(res[k])