题解 | #查找兄弟单词#
查找兄弟单词
http://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
from itertools import permutations
while True:
try:
num = input().split(' ')
n = int(num[0])
nums = num[1:n+1]
x = list(num[n+1])
k = int(num[-1])
result = []
for b in list(set(permutations(x))):
for i in range(len(nums)):
c = "".join(b)
if c == nums[i] and c != "".join(x):
result.append(c)
result.sort()
print(len(result))
if k < len(result):
print(result[k-1])
except:
break