自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 Merged String Checker Codewars 答题

At a job interview, you are challenged to write an algorithm to check if a given string, s, can be formed from two other strings, part1 and part2.The restriction is that the characters in part1 and p...

2019-09-01 12:17:48 454

原创 7.18.2 strip()的正则表达式版本

写一个函数,它接受一个字符串, 做的事情和 strip()字符串方法一样。如果只传入了要去除的字符串, 没有其他参数, 那么就从该字符串首尾去除空白字符。否则, 函数第二个参数指定的字符将从该字符串中去除。import redef nstrip(atext, b=''): sRegex = re.compile(r'(^\s*)|(\s*$)') oRegex = re....

2019-08-31 16:52:32 406

原创 7.18.1 强口令检测 实践练习

7.18.1 强口令检测写一个函数,它使用正则表达式, 确保传入的口令字符串是强口令。 强口令的定义是: 长度不少于 8 个字符, 同时包含大写和小写字符, 至少有一位数字。你可能需要用多个正则表达式来测试该字符串, 以保证它的强度。import pyperclip, relenRegex = re.compile(r'\w{8,}')lowerRegex = re.compile(r...

2019-08-31 15:48:23 259

原创 The Hashtag Generator

The marketing team is spending way too much time typing in hashtags.Let’s help them with our own Hashtag Generator!Here’s the deal:It must start with a hashtag (#).All words must have their first ...

2019-08-29 19:27:28 245

原创 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 move it....

2019-08-29 17:56:00 197

原创 Consecutive strings 练习源码

You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array.Example:longest_consec([“zone”, “abi...

2019-08-29 17:29:33 265

原创 IQ Test codewars 源码

Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given numbers differs from the others. Bob observed that one number usually differs from the other...

2019-08-29 16:31:46 252

原创 Find The Parity Outlier 练习源码

You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integ...

2019-08-29 15:28:21 323

原创 Valid Parentheses 练习

Description:Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if i...

2019-08-29 13:59:57 161

原创 array.diff 练习源码

Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.It should remove all values from list a, which are present in list b.array_...

2019-08-29 13:27:30 206

原创 Roman Numerals Decoder 罗马字母转换 练习源码

编写一个函数,将罗马数字转化成阿拉伯数字。Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don’t need to validate the form of the Roman numeral.Modern ...

2019-08-29 11:57:11 469

原创 Simple Pig Latin 练习源码

Move the first letter of each word to the end of it, then add “ay” to the end of the word. Leave punctuation marks untouched.讲一句话中的每一个单词首字母移到末尾,并在最后加上’ay’, 标点符号忽略。Examples 举例pig_it(‘Pig latin is co...

2019-08-28 23:35:28 308

原创 Equal Sides Of An Array 对称数列 练习源码

You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N....

2019-08-28 23:01:56 181

原创 Playing with digits 源码

Some numbers have funny properties. For example:有一些数字有一些特性,如下:89 --> 8¹ + 9² = 89 * 1695 --> 6² + 9³ + 5⁴= 1390 = 695 * 246288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51需要编写函数,任意的一...

2019-08-28 22:35:17 346

原创 Counting Duplicates 练习源码

Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to cont...

2019-08-28 22:01:50 219

原创 Descending Order 实践练习

Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible...

2019-08-28 21:25:34 216

原创 Persistent Bugger 实践练习

Write a function, persistence, that takes in a positive parameter num and returns its multiplicative persistence, which is the number of times you must multiply the digits in num until you reach a sin...

2019-08-28 19:56:19 482

原创 6.7 表格打印 练习题源码

编写一个名为 printTable()的函数, 它接受字符串的列表的列表,将它显示在组织良好的表格中, 每列右对齐。假定所有内层列表都包含同样数目的字符串。例如,该值可能看起来像这样:tableData = [[‘apples’, ‘oranges’, ‘cherries’, ‘banana’],[‘Alice’, ‘Bob’, ‘Carol’, ‘David’],[‘dogs’, ‘c...

2019-08-27 18:53:56 207

原创 4.10.2 字符图网格 编程练习源码

假定有一个列表的列表, 内层列表的每个值都是包含一个字符的字符串, 像这样:grid = [[’.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],[’.’, ‘O’, ‘O’, ‘.’, ‘.’, ‘.’],[‘O’, ‘O’, ‘O’, ‘O’, ‘.’, ‘.’],[‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘.’],[’.’, ‘O’, ‘O’, ‘O’, ‘O’,...

2019-08-25 23:29:26 289

原创 4.10.1 逗号代码 实践项目练习

假定有下面这样的列表:spam = [‘apples’, ‘bananas’, ‘tofu’, ‘cats’]编写一个函数,它以一个列表值作为参数,返回一个字符串。该字符串包含所有表项,表项之间以逗号和空格分隔,并在最后一个表项之前插入 and。例如,将前面的 spam 列表传递给函数,将返回’apples, bananas, tofu, and cats’。但你的函数应该能够处理传递给...

2019-08-25 22:46:54 626

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除