自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 checkio Stair Steps

题目: There is a staircase with N steps and two platforms; one at the beginning, the other at the end of the stairs. On each step a number is written (ranging from -100 to 100 with the exception of 0.) Zeros are written on both platforms. You start going up

2020-07-26 22:31:10 125

原创 checkio Rectangles Union

题目: Your mission is to calculate the area covered by a union of rectangles. The rectangles can have a non-empty intersection, which means that a simple sum of given rectangle areas doesn’t work. Every rectangle is represented as 4 integers. The first two i

2020-07-24 19:49:37 121

原创 checkio Reversed Permutation Index

题目: You are given the length of the permutation (an integer) and the permutation index (an integer starting from 1). The task is to calculate one of the permutations of the consecutive integers (starting from 0) and return it (an iterable of integers). For

2020-07-24 16:22:59 98

原创 checkio String Conversion

题目: You are given two strings, line1 and line2. Answer, what is the smallest number of operations you need to do in order to transform line1 into the line2? Possible operations: Delete one letter from one of the strings. Insert one letter into one of the s

2020-07-24 14:49:14 89

原创 checkio The First Working Day

题目: As the input you’ll get the date of the first vacation day in the format ‘YYYY-MM-DD’ and the total number of vacation days. Your task is to find out which day will be the first working day after the vacation. If it’ll be Saturday or Sunday then it sho

2020-07-24 12:09:47 127

原创 checkio Weekend Counter

题目: Sofia has given you a schedule and two dates and told you she needs help planning her weekends. She has asked you to count each day of rest (Saturday and Sunday) starting from the initial date to final date. You should count the initial and final dates

2020-07-24 11:07:30 77

原创 checkio Useless Flights

题目: Here you have a flight schedule by which you need to find out whether all flights are really necessary. For example: If from the point A to point C you can fly directly for $ 100, but you can also go through the point B (from A to B, and then from B to

2020-07-22 17:20:18 101

原创 checkio Area of a Convex Polygon

题目: here is a convex polygon on a coordinate plane. This polygon is presented as a list of vertices coordinates. Each vertex is connected sequentially with the last connecting back to the first. A polygon has N vertices. You should write a program that wil

2020-07-22 14:37:44 86

原创 checkio Evenly Spaced Trees

题目: You need to add some trees and keep them evenly spaced. You are given a list of integers as an input value. This is the position of an existing tree. You must return the minimum number of additional trees needed so that they could be evenly spaced. Pos

2020-07-22 13:29:30 110

原创 checkio Secret Message

题目: Ever tried to send a secret message to someone without using the postal service? You could use newspapers to tell your secret. Even if someone finds your message, it’s easy to brush them off as paranoid and as a conspiracy theorist. One of the simplest

2020-07-21 18:15:08 188

原创 checkio Remove Brackets

题目: Before solving this mission, you can try to solve the “Brackets” mission. Your task is to restore the balance of open and closed brackets by removing the unnecessary ones, while trying to use the minimum number of deletions. Only 3 types of brackets ()

2020-07-21 17:06:19 406

原创 checkio Expand Intervals

题目: An interval of consecutive positive integers can be succinctly described as a tuple that contains first and last values. For example, the interval that contains the numbers 5, 6, 7, 8, 9 can be described as (5,9). Multiple intervals can be united toget

2020-07-16 14:37:56 125

原创 checkio Merge Intervals

题目: You are given a sequence of intervals, as tuples of ints where the tuples are sorted by their first element in ascending order. It is your task to minimize the number of intervals by merging those that intersect or by removing intervals fitting into an

2020-07-15 21:54:04 94

原创 checkio Create Intervals

题目: From a set of ints you have to create a list of closed intervals as tuples, so the intervals are covering all the values found in the set. A closed interval includes its endpoints! The interval 1…5, for example, includes each value x that satifies the

2020-07-15 18:34:07 122

原创 checkio The Highest Building

题目: Input: Heights of the buildings as a 2D-array. Output: The number of the highest building and height of it as a list of integers (Important: in this task the building numbers starts from “1”, not from “0”) Example: highest_building([[0, 0, 1, 0], [1, 0

2020-07-14 22:17:39 124

原创 checkio The Cheapest Flight

题目: “We need to fly home as cheaply as possible so that more money is left for gifts. Aunt Lidia asked for different kinds of cheeses, and Vasya wanted a new toy car. I’ve been looking at the schedule for quite a while and I’m starting to think that some p

2020-07-11 21:21:31 287

原创 checkio The End of Other

题目: In this task, you are given a set of words in lower case. Check whether there is a pair of words, such that one word is the end of another (a suffix of another). For example: {“hi”, “hello”, “lo”} – “lo” is the end of “hello”, so the result is True. In

2020-07-09 22:27:44 88

原创 checkio The Warriors

题目: Warrior 和 Knight,两者的生命值(50点)相同但攻击力不相同,Warrior 攻击力为 5 点,Knight 攻击力为 7 点,他们之间不断来回攻击,每一个回合,被攻击者将减去相应的生命值,战斗以其中之一的死亡而告终。 链接: https://py.checkio.org/en/mission/the-warriors/ 代码: class Warrior: health = 50 is_alive = True attack = 5 class Knight(Wa

2020-07-09 14:03:28 120

原创 checkio Unix Match. Part 2

题目: [seq] matches any character in seq, for example [123] means any character - ‘1’, ‘2’ or ‘3’ [!seq] matches any character not in seq, for example [!123] means any character except ‘1’, ‘2’ and ‘3’ 实例: unix_match(‘somefile.txt’, ‘somefile.txt’) == True u

2020-07-09 12:50:19 152

原创 checkio Unix Match. Part 1

题目: matches everything ? matches any single character Input: Two arguments. Both are strings. Output: Bool. Example: unix_match(‘somefile.txt’, ‘’) == True unix_match(‘other.exe’, '’) == True unix_match(‘my.exe’, ‘*.txt’) == False unix_match(‘log1.txt’, ‘

2020-07-07 17:58:39 197 1

原创 checkio What Is Wrong With This Family?

题目: You have a list of family ties between father and son. Each element on this list has two elements. The first is the father’s name, the second is the son’s name. All names in the family are unique. Check if the family tree is correct. There are no stran

2020-07-07 16:15:01 222

原创 checkio Similar Triangles

题目: 相似三角形是True 链接: https://py.checkio.org/en/mission/similar-triangles/ 代码: def angle_s(a): v01 = (a[1][0]- a[0][0], a[1][1]- a[0][1]) v02 = (a[2][0]- a[0][0], a[2][1]- a[0][1]) s0 = (v01[0]*v02[0] + v01[1]*v02[1])/(v01[0]**2+v01[1]**2)**0.5/(v02[0]**2

2020-07-07 15:30:49 186

原创 checkio Surjection Strings

题目: 两个字符串可不可以成某种规律映射 Example: isometric_strings(‘add’, ‘egg’) == True isometric_strings(‘foo’, ‘bar’) == False Precondition:both strings are the same size 链接: https://py.checkio.org/en/mission/isometric-strings/ def isometric_strings(str1: str, str2: str)

2020-07-07 14:17:00 176

原创 checkio Ascending List

题目: list无重复数字,都是从小到大排列为True 链接: https://py.checkio.org/en/mission/ascending-list/ 代码 from typing import Iterable def is_ascending(items: Iterable[int]) -> bool: a = items aa = list(set(a)) b = sorted(a) if len(aa) != len(a): r =

2020-07-07 13:37:27 161

原创 checkio All Upper II

题目: Check if a given string has all symbols in upper case. If the string is empty or doesn’t have any letter in it - function should return False. 链接: https://py.checkio.org/en/mission/all-upper-ii/ 代码 def is_all_upper(text: str) -> bool: return tex

2020-07-07 11:11:36 204

原创 checkio Acceptable Password II

题目: 判断字符串长度大于6,里面至少有一个数字是True 链接: https://py.checkio.org/en/mission/acceptable-password-ii/ 代码: import re a = "muchlonger5" b = re.findall('\d', a) if b != []: if len(a) > 6: r = True else: r = False else: r = False print(r) ...

2020-07-07 10:48:38 365

原创 checkio Digits Multiplication

题目: 数字中每一个非零元素相乘 链接; https://py.checkio.org/en/mission/digits-multiplication/ 思路: 先转化为字符串,把每一个元素分离出来 代码: def checkio(number: int) -> int: b = str(number) c = 1 for i in b: if int(i)!= 0: c = c*int(i) return c ...

2020-07-06 21:25:10 109

原创 checkio Words Order

题目: You have a text and a list of words. You need to check if the words in a list appear in the same order as in the given text. Cases you should expect while solving this challenge: a word from the list is not in the text - your function should return Fal

2020-07-05 21:35:53 250

原创 checkio The Flat Dictionary

题目: https://py.checkio.org/en/mission/flatten-dict/ 代码: a = {"key": {"deeper": {"more": {"enough": "value"}}}} s = [((), a)] result = {} while s: p, c = s.pop() if not c: result['/'.join((p))] = '' for k, v in c.items(): if isin

2020-07-05 20:23:15 156

原创 checkio Determine the Order

题目: 对字母进行排序,排序规则根据在列表中字符串中的排列位置(隐含了如果没有在字符串中有明确顺序就根据字母表顺序排,这个隐含条件没有表明在代码里,所以有些算例通不过) 链接: https://py.checkio.org/en/mission/determine-the-order/ Example: checkio([“acb”, “bd”, “zwa”]) == “zwacbd” checkio([“klm”, “kadl”, “lsm”]) == “kadlsm” checkio([“a”, “b”

2020-07-05 18:16:00 256

原创 checkio Flatten a List

题目: 把嵌套的List展平 Example: flat_list([1, 2, 3]) == [1, 2, 3] flat_list([1, [2, 2, 2], 4]) == [1, 2, 2, 2, 4] flat_list([[[2]], [4, [5, 6, [6], 6, 6, 6], 7]]) == [2, 4, 5, 6, 6, 6, 6, 6, 7] flat_list([-1, [1, [-2], 1], -1]) == [-1, 1, -2, 1, -1] Precondition:

2020-07-05 16:15:50 110

原创 checkio Compress List

题目: 删除列表中连续重复元素中除了一位之外的后几位 题目链接: https://py.checkio.org/en/mission/compress-list/ 思路:先判断列表是不是空列表,如果不是,现将第一位元素取出来,然后用一个for循环选出和前一位元素不一样的元素,append 代码: def compress(items: list) -> Iterable: a = items if a != []: x = [a[0]] for i in r

2020-06-28 13:53:02 95

原创 checkio Roman numerals

Roman numerals 题目: 基本的罗马数字表示规则 The first ten Roman numerals are: I, II, III, IV, V, VI, VII, VIII, IX, and X. Numeral Value I 1 (unus) V 5 (quinque) X 10 (decem) L 50 (quinquaginta) C 100 (centum) D 500 (quingenti) M 1,000 (mille) 目标:Precondition: 0 < n

2020-06-28 10:51:54 157

空空如也

空空如也

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

TA关注的人

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