![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
note
soufal
going
展开
-
Python学习记录(二)----高级特性
一个使用生成器生成斐波拉契数列的例子#利用生成器生成斐波那契数列#普通函数生成斐波拉契数列def Fibonacci(num): n0, n1 = 1, 1 for i in range(num): print(n0, end=" ") n0, n1 = n1, n0+n1 print('\n')Fibonacci(6)#生成器...原创 2018-10-23 10:25:46 · 159 阅读 · 0 评论 -
Codewars第十三天–Simplifying multilinear polynomials
Codewars第十三天–Simplifying multilinear polynomials题目描述: 当我们上中学时被要求简化数学表达式,如“3x-yx + 2xy-x”(或通常更大),这很容易(“2x + xy”)。但告诉你的电脑,我们会看到!写一个函数:简化(聚) 在输入中取一个字符串,表示整数系数中的多线性非常数多项式(如“3x-zx + 2xy-x”),并返回另一个字...原创 2018-08-29 11:16:38 · 478 阅读 · 0 评论 -
Codewars第八天--Valid Parentheses(带有字母的单个括号匹配)
Codewars第八天–Valid Parentheses(带有字母的单个括号匹配)题目描述: 该题只需要匹配一种括号,但是其中会有字母干扰。 比如测试用例为:Test.assert_equals(valid_parentheses(" ("),False)Test.assert_equals(valid_parentheses(")test"),False)Test.asser...原创 2018-08-21 19:52:40 · 387 阅读 · 0 评论 -
Codewars第八天–Valid Braces
Codewars第八天–Valid Braces题目描述: 这道题是常见的不同括号之间的匹配问题。给定一个括号序列,给出他是否匹配的结果,匹配则返回True ,否则返回False 。 例如:"(){}[]" => True"([{}])" => True&原创 2018-08-21 17:42:31 · 257 阅读 · 0 评论 -
Codewars第八天--Good vs Evil
Codewars第八天–Good vs Evil题目描述:霍比特人:1男子:2精灵:3矮人:3老鹰队:4巫师:10在邪恶的一面,我们有:兽人:1男子:2Wargs:2哥布林:2Uruk Hai:3巨魔:5巫师:10输入:该函数将给出两个参数。每个参数都是由单个空格分隔的字符串。每个字符串将包含善恶方面的每个种族的数量。第一个参数将按以下顺序包含go...原创 2018-08-21 17:14:15 · 241 阅读 · 0 评论 -
Codewars第八天--Roman Numerals Encoder
Codewars第八天–Roman Numerals Encoder题目描述: 给定一个数字n ,返回该数字对应的罗马数字。 在罗马技术中 1990 : 1000=M, 900=CM, 90=XC; 结果为: MCMXC. 2008 可以被写作: 2000=MM, 8=VIII; 结果为: MMVIII. 1666 被描述为: MDCLXVI。但是相同的罗马字不能够超过三个,比如9 不能够...原创 2018-08-21 16:13:31 · 227 阅读 · 0 评论 -
Codewars第十一天–PermutationsPrimes in numbers
Codewars第十一天–PermutationsPrimes in numbers题目描述: 给定一个数n ,返回他的素因子。 例如:Example: n = 86240 should return "(2**5)(5)(7**2)(11)"参考的比较好的代码如下:def primeFactors(n): i, j, p = 2, 0, [] while ...原创 2018-08-24 15:23:34 · 322 阅读 · 0 评论 -
Codewars第十一天–PermutationsNumber of trailing zeros of N!
Codewars第十一天–PermutationsNumber of trailing zeros of N!题目描述: 给定一个数n ,返回n 的阶乘中末尾0 的个数。比如:zeros(6) = 1# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zerozeros(12) = 2# 12! = 479001600 --&...原创 2018-08-24 11:26:01 · 172 阅读 · 0 评论 -
Codewars第十天–Permutations
Codewars第十天–Permutations题目描述: 这是一道常见的全排列题目。需要返回输入字符串的所有排列并删除重复项(如果存在)。 例如:permutations('a'); # ['a']permutations('ab'); # ['ab', 'ba']permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab',...原创 2018-08-23 17:10:48 · 427 阅读 · 0 评论 -
剑指offer---连续子数组的最大和
剑指offer—连续子数组的最大和题目描述:给定一个输入数组,输出该数组的中所以子数组的和的最大值。时间复杂度为O(n)。思路: 一、由于数组中有正有负,因此我们可以顺序遍历一般数组,依次累加每一个数字。如果累加到某一个数字i时的结果比他本身还小时,就说明前i-1个数字构成的子序列和还没有这一个数字i大。故将之前得到的和抛弃,选择当前数字i作为新的最大和,继续循环。这样值循环一次得到的结...原创 2018-09-04 16:58:26 · 128 阅读 · 0 评论 -
2018迅雷校园招聘客户端在线笔试B卷---输入一个有符号整数,输出该整数的反转值。
2018迅雷校园招聘客户端在线笔试B卷—输入一个有符号整数,输出该整数的反转值。题目描述: 输入一个有符号整数,输出该整数的反转值。 代码如下:num = list(input())if num[0] != '-': num = num[::-1]else: num = num[::-1] temp = num.pop() num.insert(0,...原创 2018-09-07 21:31:30 · 1052 阅读 · 2 评论 -
剑指offer---旋转数组的最小数字
剑指offer—旋转数组的最小数字题目描述:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 该题考查的是如何使用时间复杂度小于O(n) 的方法来找到这个最小值,...原创 2018-09-07 23:48:25 · 117 阅读 · 0 评论 -
Python学习记录(一)-----数据类型
重新开始复习和巩固Python的知识,以思维导图的形式来记录,感觉这种方式挺好的,适合自己学习和总结。原创 2018-10-23 10:23:13 · 161 阅读 · 0 评论 -
剑指offer---两个栈实现队列
剑指offer—两个栈实现队列题目描述: 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。使用一个栈stack1 来存储队列插入的值,使用另一个栈stack2 来进行队列删除。因为队列是先进先出,而栈是后进先出的,因此插入将先把值插入到stack1 中,删除时需要改变值的顺序,将stack1 中栈顶的值一次pop() 到stack2 中,此时stack...原创 2018-09-07 10:38:11 · 140 阅读 · 0 评论 -
剑指offer---从头到尾打印列表
剑指offer—从头到尾打印列表 题目描述: 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。解题思路: 这道题不难,可以使用栈来实现,将原数组的值依次存入一个新的栈中。然后再弹出。代码如下:# -*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self.val ...原创 2018-09-06 23:47:37 · 207 阅读 · 0 评论 -
“校园舆情监测系统”网站设计及网页编辑总结
“校园舆情监测系统”网站设计及网页编辑总结这是很早之前,13年左右在做舆情系统前端时写的一些总结,现在放到博客上,以防丢失。 后端使用Django Web 框架。 前端使用django 的python模板语言开发。一、网页编程基础知识<html> <head> <title>校园舆情监测系统</title> </...原创 2018-09-16 12:45:08 · 1935 阅读 · 0 评论 -
(Python实现)剑指offer---斐波那契数列
(Python实现)剑指offer—斐波那契数列题目描述:大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n&amp;lt;=39 这个题目也不难,第一反应应该是使用递归来编写代码,我的第一反应也是,但是看过书后发现,如果使用递归的话,当n 很大时,递归计算的时间复杂度时以n 的指数方式增长的。复杂度过高。 如果使用循环的话,其时间复杂度恒为O...原创 2018-09-09 23:23:24 · 297 阅读 · 0 评论 -
(Python实现)剑指offer---重建二叉树
(Python实现)剑指offer—重建二叉树题目描述:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 思路:可以根据前序遍历中的第一个节点为根节点的值,去扫描中序遍历的序列,可以确定根节点在中序遍历...原创 2018-09-09 23:06:17 · 479 阅读 · 0 评论 -
Codewars第十四天–Numbers that are a power of their sum of digits
Codewars第十四天–Numbers that are a power of their sum of digits题目描述: 数字81有一个特殊的属性,其数字之和的某个幂等于81(九的平方)。 八十一(81),是拥有这个属性的第一个数字(不考虑一位数字)。 下一个是512.让我们看两个案例的细节 8+1=98+1=98 + 1 = 9且 92=8192=819^2 = 81 51...原创 2018-09-02 16:12:28 · 256 阅读 · 0 评论 -
LeetCode第一题-----三数之和
题目要求: 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。注意:答案中不可以包含重复的三元组。例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],满足要求的三元组集合为: [-1, 0, 1], [-1, -1, 2]]cla...原创 2018-08-30 16:48:21 · 154 阅读 · 0 评论 -
Codewars第十二天–What's a Perfect Power anyway?
Codewars第十二天–What’s a Perfect Power anyway?题目描述: 你的任务是检查一个给定的整数是一个完美的幂指数。 如果它是一个完美的幂指数,则返回一对m和k,其中mk=nmk=nm^k = n。 否则返回None。注意:对于完美的功率,可能有几对。 例如,81 = 3 ^ 4 = 9 ^ 2,因此(3,4)和(9,2)都是有效的解决方案。 代码如下:...原创 2018-08-27 14:22:16 · 380 阅读 · 0 评论 -
Codewars第三天--Binary Addition
Codewars第三天–Binary Addition题目描述: Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition. The binary number re...原创 2018-07-21 11:57:31 · 425 阅读 · 0 评论 -
Codewars第二天--Disemvowel Trolls
Codewars第二天–Disemvowel Trolls继续刷题,题目描述为: Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing ...原创 2018-07-20 14:54:03 · 570 阅读 · 0 评论 -
Codewars第二天--Complementary DNA
Codewars第二天–Complementary DNA开始在Codewars刷Python3题,发现基本知识都忘完了,边刷边复习边记录。 8kyu>>7kyu Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" f...原创 2018-07-20 10:23:38 · 457 阅读 · 0 评论 -
Codewars第五天--Sort the odd
Codewars第五天–Sort the odd题目描述: You have an array of numbers. Your task is to sort ascending odd numbers but even numbers must be on their places. Zero isn't an odd number and you don't need to mov...原创 2018-07-24 21:21:48 · 299 阅读 · 0 评论 -
Codewars第五天--Stop gninnipS My sdroW!
Codewars第五天–Stop gninnipS My sdroW!题目描述: Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the na...原创 2018-07-24 20:54:02 · 751 阅读 · 0 评论 -
Codewars第四天--Sum of Digits / Digital Root
Codewars第四天–Sum of Digits / Digital Root题目描述: In this kata, you must create a digital root function. A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the...原创 2018-07-23 21:03:17 · 604 阅读 · 0 评论 -
Codewars第四天--Two to One
Codewars第四天–Two to One题目描述: Take 2 strings s1 and s2 including only letters from ato z. Return a new sorted string, the longest possible, containing distinct letters, each taken only once - coming...原创 2018-07-23 17:33:03 · 499 阅读 · 0 评论 -
论文Prediction of Prediction of off-target activities for the end-to-end design of CRISPR guide RNA 笔记
Prediction of Prediction of off-target activities for the end-to-end design of CRISPR guide RNAs论文链接摘要:脱靶效应可导致次优基因编辑结果,是其发展的瓶颈。使用基于两个相互关联的机器学习模型的方法来预测脱靶效应—叫做Elevation。 对独立的guide-target 对进...原创 2018-06-29 10:27:20 · 843 阅读 · 0 评论 -
Codewars第三天--The museum of incredible dull things
Codewars第三天–The museum of incredible dull things题目描述: The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the m...原创 2018-07-21 13:03:42 · 527 阅读 · 0 评论 -
Codewars第四天--Find the stray number
Codewars第四天–Find the stray number题目描述: You are given an odd-length array of integers, in which all of them are the same, except for one single number. Complete the method which accepts such an a...原创 2018-07-22 14:50:56 · 229 阅读 · 0 评论 -
Codewars第三天--Unique In Order
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of e...原创 2018-07-22 18:06:14 · 351 阅读 · 0 评论 -
Codewars第七天--Give me a Diamond
Codewars第七天–Give me a Diamond题目描述:很简单的一道题,给定一个值N ,返回一个以* 构成的钻石形状的字符。 如果n 的值为偶数或者负数,则返回None。 如果n=3 ,则输出: * *** *具体代码如下:def diamond(n): if n > 0 and n % 2 == 1: diamond = ...原创 2018-08-20 10:28:54 · 336 阅读 · 0 评论 -
Codewars第九天–Regex Password Validation
Codewars第九天–Regex Password Validation一个很有意思的题目,只是要求写出一个正则表达式来判断输入的密码是否符合以下标准: * 至少有六个字符长 * 包含一个大写字母 * 包含一个小写字母 * 包含一个数字 有效密码只能是字母数字字符。 相应的正则表达式如下:regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^\W_...原创 2018-08-22 17:33:02 · 315 阅读 · 0 评论 -
Codewars第九天–Length of missing array
Codewars第九天–Length of missing array题目描述: 你得到一个数组数组。 如果按长度对数组进行排序,您将看到它们的长度值是连续的。 但是缺少一个阵列! 您必须编写一个返回缺失数组长度的方法。 例如:Example:[[1, 2], [4, 5, 1, 1], [1], [5, 6, 7, 8, 9]] --> 3如果数组数组为null /...原创 2018-08-22 17:15:38 · 161 阅读 · 0 评论 -
Codewars第九天–Can you get the loop ?
Codewars第九天–Can you get the loop ?题目描述: 您将获得一个节点,该节点是链接列表的开头。 此列表始终包含尾部和循环。 您的目标是确定循环的长度。 例如,在下图中,尾部的大小为3,循环大小为11。 在这里,可以使用node.next 来获得下一个节点。 思想:在这里只需要找到某一个节点有着两个前驱即可。这个节点就可以当做循环列表的开头和结尾。他的大...原创 2018-08-22 16:18:38 · 575 阅读 · 0 评论 -
Codewars第六天--Where my anagrams at?
Codewars第六天–Where my anagrams at?题目描述: What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:'abba' &amp; 'baab' == true'abba' &amp; ...原创 2018-08-16 15:36:22 · 277 阅读 · 0 评论 -
Codewars第三天--Create Phone Number
Codewars第三天–Create Phone NumberWrite a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.Example: create_phone_...原创 2018-07-22 19:43:24 · 547 阅读 · 1 评论 -
Codewars第三天--Breaking chocolate problem
Your task is to split the chocolate bar of given dimension n x m into small squares. Each square is of size 1x1 and unbreakable. Implement a function that will return minimum number of breaks needed....原创 2018-07-22 18:53:42 · 456 阅读 · 0 评论 -
Codewars第三天--Largest 5 digit number in a series
Codewars第三天–Largest 5 digit number in a series In the following 6 digit number:28391091 is the greatest sequence of 2 consecutive digits.In the following 10 digit number:123456789067890...原创 2018-07-22 18:37:59 · 323 阅读 · 0 评论