- 博客(14)
- 资源 (3)
- 收藏
- 关注
原创 Linked Lists - Sorted Insert
https://www.codewars.com/kata/linked-lists-sorted-insert/train/pythonWrite a SortedInsert() function which inserts a node into the correct location of a pre-sorted linked list which is sorted in as...
2019-03-28 17:12:06
279
原创 Prize Draw
https://www.codewars.com/kata/5616868c81a0f281e500005cTo participate in a prize draw each one gives his/her firstname.Each letter of a firstname has a value which is its rank in the English alpha...
2019-03-27 17:49:37
1184
原创 Grill it!
https://www.codewars.com/kata/grill-it/train/pythonIntroductionA grille cipher was a technique for encrypting a plaintext by writing it onto a sheet of paper through a pierced sheet (of paper or...
2019-03-27 16:25:12
278
原创 Josephus Permutation
https://www.codewars.com/kata/5550d638a99ddb113e0000a2This problem takes its name by arguably the most important event in the life of the ancient historian Josephus: according to his tale, he and ...
2019-03-22 09:21:41
310
原创 String incrementer
https://www.codewars.com/kata/54a91a4883a7de5d7800009c题目:Your job is to write a function which increments a string, to create a new string. If the string already ends with a number, the number sh...
2019-03-21 11:23:34
504
原创 Range Extraction 4ku
https://www.codewars.com算法的练习,题目:A format for expressing an ordered list of integers is to use a comma separated list of eitherindividual integers or a range of integers denoted by the starti...
2019-03-21 11:13:47
583
原创 单链表操作
1、单链表反转力扣206# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = None# 头插入法class Solution: def reverseList(self,...
2019-03-17 11:10:39
102
原创 用生成器读取文件
背景有一个100G 的文本文件,内容只有一行,内容间用 {|} 这样的字符串分割,目前需要读取里面的配置信息。文件内容示例abc=123{|}ccc=345{|}config_file_name="test.conf"{|}eii=432困难无法直接一次性的读入内存,电脑会奔溃,同时也无法一行一行的读取,因为文件只有一行;解决思路使用生成器,依次去迭代读出,可以避免将计算机主...
2019-01-15 20:09:00
611
原创 日志中的日期替换
情景:某个日志中有大量的日期,想把日期格式调整统一如:..12/21/2018 10:46:25 [root] WARNING: userinfo error http://guba.eastmoney.com/news,of000038,114062178.html12/21/2018 10:46:25 [root] WARNING: userinfo error http://gu...
2018-12-25 19:53:02
483
原创 根据字典中的值的大小,对字典排序
思路:将字典中的各项转换为元组,再通过内置的sorted函数进行排序使用sorted函数from random import shufflefrom random import randintnames = list('abcdefghig')print(names)# ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g']# 进行洗...
2018-12-25 14:55:58
1459
原创 为元组中的每个元素命名, 提高程序可读性
如有一些学生信息字段,字段是固定的,(姓名,年龄,性别,邮箱),我们选择用元组保存姓名年龄性别邮箱jime15男122@qq.comtom13男123@qq.com使用如下数据结构保存:(‘jim’,15,‘male’,‘122@qq.com’)(‘tom’,13,‘male’,‘123@qq.com’)存在的问题:def xxx_fun...
2018-12-25 14:03:29
357
原创 在列表, 字典, 集合中根据条件筛选数据
在实际项目中可能会遇到下面的简单需求:1、将 [1,2,-2,43,-35,…] 列表中的负数过滤掉,只保留大于等于0的数;2、输出 {‘Jim’:78, ‘Tom’:90, ‘Bob’:93, ‘Max’:88} 列表中的考试成绩大于90分的同学;3、筛选出集合 {6,5,32,33,96,54} 中能被3整除的数;思路 使用列表、字典、集合的解析式 使用filter过滤函数实...
2018-12-25 10:06:10
840
原创 列表训练题
题目:将 下面的列表完全展开,如:list2=[[1,2],[3,4]] 完全展开后为:[1,2,3,4]list1=[11,[12,[13,14]],[100,200]]list2=[[1,2],[3,4]]list3=[[1,2],[3, [4,5,6]]]way1: 屌丝用法result = []def flatten(iter): if type(i...
2018-10-24 13:55:44
196
转载 python练习1
1、自然数10以下的能被3或者5整除的有3,5,9,那么这些数字的和是23,求能被3或者5整除的1000以内数字的和>>> print(sum([i for i in range(1,1000) if i%3==0 or i%5==0]))233168或者用reduce>>> from functools import reduce>&...
2018-10-19 11:11:02
446
MySQL DBA修炼之道
2017-11-22
SpringMVC框架
2013-08-03
高性能MySQL(第3版)
2017-11-22
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人