jdzzj
发表于 2020-2-3 12:04:39
def Kstart(self, aString):
counts=[]
times=0
bString= "".join(list(set(aString)))
for each in bString:
counts.append(aString.count(each))
counts.sort(reverse=True)
i=1
while i<len(counts):
while counts in counts[:i]:
times+=1
counts-=1
if counts<=0:
times+=sum(counts)
return times
i+=1
return times
catwine1990
发表于 2020-3-21 18:31:11
#不重复个数字母
def fun320(str):
dic = {}
for each in str:
dic = str.count(each)
value_lst = []
for value in dic.values():
value_lst.append(value)
l = len(value_lst)
value_lst.sort(reverse = True)
count = 0
#print(value_lst)
for i in range(l):
if i < l-1:
if value_lst <= value_lst and value_lst >= 1:
count += value_lst-value_lst+1
value_lst = value_lst - 1
if value_lst == 0:
count +=value_lst
value_lst = 0
return count
776667
发表于 2020-10-5 11:44:09
def fun320(x):
result = 0
count_x = []
for i in set(x):
if x.count(i) not in count_x:
count_x.append(x.count(i))
else:
count_i = x.count(i)
while True:
result += 1
count_i -= 1
if count_i not in count_x and count_i:
count_x.append(count_i)
break
elif not count_i:
break
return result