s = 'abcdefg' l = len(s) t = s[0] + str(l-2) + s[l-1] a = [t] a.extend([s[:j] + str(i) + s[i+j:] for i in range(l-3, 0, -1) for j in range(1, l-2)]) a.append(s) print ' '.join(a) 无非也是暴力的解决,思路和上楼的一样, a5g a4fg ab4g abc4 abcd4 a3efg ab3fg abc3g abcd3 a2defg ab2efg abc2fg abcd2g a1cdefg ab1defg abc1efg abcd1fg abcdefg
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务