1.单词分析
代码:
str = input()
max = 0
maxs = 'a'
for s in str:
cnt = str.count(s)
if cnt>max:
max = cnt
maxs = s
elif cnt == max:
if s < maxs:
maxs = s
print(maxs)
print(max)
2.门牌制作
代码:
import os
import sys
num = 0
for i in range(1,2021):
m = str(i)
num += m.count('2')
print(num)
3.卡片
解法1
num={0:2021,1:2021,2:2021,3:2021,4:2021,5:2021,6:2021,7:2021,8:2021,9:2021}
i=1
num[1]-=1
while num[1]!=0:
i+=1
a=[int(j) for j in str(i)]
for j in a:
num[j]-=1
print(i)
解法1
num=0
for i in range(99999999):
num += str(i).count("1")
if num>2021:
break
print(i-1)