level 4
赢界驸马666666
楼主
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
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个相同的,怎么改?哪位帅哥美女会的,帮个忙呗!!!