大磊子
大磊子
全部文章
分类
题解(15)
归档
标签
去牛客网
登录
/
注册
大磊子的博客
全部文章
(共17篇)
题解 | #统计字符#
clis = 'zxcvbnmasdfghjklqwertyuiop' nlis = '12334567890' space = ' ' string = input().lower() chars,space...
Python3
2022-08-12
0
268
题解 | #判断两个IP是否属于同一子网#
zwym = input().split('.') ip1 = input().split('.') ip2 = input().split('.') def is_valid(ls): &nb...
Python3
2022-08-04
1
280
题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
n = int(input()) print(2.875*n) print(0.03125*n) 服了这么写的那个大佬。笑尿了
Python3
脑筋急转弯
2022-08-04
4
348
题解 | #字符串加密#
算是最直接的想法吧 key = input() string = input() l1 = "abcdefghijklmnopqrstuvwxyz" l2 = '' for i in key...
Python3
2022-08-03
0
227
题解 | #单词倒排#
主要用了正则表达式来替换,果然我还是得好好学学正则 import re line = input() res = re.sub(r'[^a-zA-Z]', ' ', line).split(' ') for i in res[::-1]: print(i,end=' ')
Python3
2022-03-14
0
344
题解 | #字符串合并处理#
def trans(c): ls = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F'] if c not in ls: return c ...
Python3
2022-03-14
0
372
题解 | #查找兄弟单词#
判断兄弟词的办法很多,我用的是将字符串转成列表排序后进行比对,条件就是原本的字符串不一样,排序后的字符串一样。 s = input().split(' ') num = s[0] words = s[1:-2] w = s[-2] nw = ''.join(sorted(list(w))) k =...
Python3
2022-03-03
0
316
题解 | #合唱队#
参考了高赞的回答,为了加深自己的理解,手撸了一遍二分查找的代码。总的来说还是要自己敲一遍,一行行理解的快一些。 #二分查找,其中ls是从左到右升序 def find_pos(ls, num,start = 0, end = None): if end == None: end...
Python3
2022-03-03
5
991
题解 | #删除字符串中出现次数最少的字符#
while True: try: string = input() dictionary = {} for i in string: if i not in dictionary: dic...
Python3
2022-03-03
0
573
题解 | #简单密码#
想法大概都差不多,就是在循环里面加一个break来节约一些资源 chars = ['abc','def','ghi','jkl','mno','pqrs','tuv','wxyz'] string = input() newpswd = '' for i in string: if ord(...
Python3
2022-03-03
1
494
首页
上一页
1
2
下一页
末页