菜鸟问题!!!!!!
python3吧
全部回复
仅看楼主
level 4
def find_same(a, b, c, d, e,f,g,h):
st = ""
dic = {a: len(a),b: len(b), c: len(c), d: len(d), e: len(e),f:len(f),g:len(g),h:len(h)}
new_dic = sorted(dic.items(), key=lambda x: x[1])[0][0]
for i in new_dic:
if i in a and i in b and i in c and i in d and i in e and i in g and i in f and i in h:
st += i
return st
a = ('++++')
b = ('++ ++')
c = ('++++')
d = ('++++')
e = ('+ +++')
f = ('++++' )
g = ('++++' )
h=('++ ++')
x=('++-++')
z=('++++')
aaaa = itertools.permutations([a, b, c, d, e, f, g,h,x,z], 8)
result = []
for i in aaaa:
ms = find_same(i[0], i[1], i[2], i[3], i[4],i[5],i[6],i[7])
if ms != "": 咋改
result.append(ms)
print("".join(set(result)))
这个是打印出来全部相同的,我要打印出来只有6个和少于6个相同的,怎么改?哪位帅哥美女会的,帮个忙呗!!!
2023年06月22日 21点06分 1
level 1
[汗][汗][汗]加个判断不就行。[汗][汗]
2023年06月23日 18点06分 2
帮帮忙吧!
2023年06月24日 07点06分
level 4
唉!不会呀!也就是业余爱好而已,会的帮我写句代码呀!
2023年06月24日 07点06分 3
1