![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
checkio notes
复醉
这个作者很懒,什么都没留下…
展开
-
The Warriors []
主要就是在fight()中对数据进行更新# The Warriorsclass Warrior: health = 50 attack = 5 is_alive = Trueclass Knight(Warrior): attack = 7def fight(unit_1, unit_2): count_1= unit_1.health /uni...原创 2018-10-25 21:55:13 · 344 阅读 · 0 评论 -
The Hamming Distance [位运算]
前面:>> #右移<< #左移| #位或 & #位与^ #位异或~ #非0b11 << 2 #输出为12, 即0b11000b11 >> 1 #输出为1, 即0b1-8 >> 3 #输出为-1 '''在Python中如果符号位为0,则右移后高位补0,如果符号位为1,则...原创 2018-11-05 00:30:26 · 342 阅读 · 0 评论 -
Number Base [int 进制]
些许:# 从2 进制到 36 进制int('f',16) int('10100111110',2) # 10 转 16hex(1033)# 10 转 2bin(10)# 10 到 8oct(11)代码:# Number Base# def checkio(str_number, radix): try: return int(str_numb...原创 2018-11-04 23:55:44 · 245 阅读 · 0 评论 -
Best Stock [最大 键]
思路: 用 max(dict,key=dict.get) 方法 返回keydef best_stock(data): # your code here return max(data,key=dict.get)if __name__ == '__main__': print("Example:") print(best_stock({ 'C...原创 2018-11-04 20:57:25 · 249 阅读 · 0 评论 -
First Word [re search ]
思路: 用 re 的匹配## First Word# import redef first_word(text: str) -&gt; str: """ returns the first word in a given text. """ # your code here pat1 = "[a-zA-Z']原创 2018-11-04 20:36:58 · 193 阅读 · 0 评论 -
Keys and Locks 求教[疑似 python bug]
Keys and Locks题目思路:去除纯 0 做 3 个旋转的 copy [90, 180, 270] , 对应关系 for y in range(row_1): for x in range(column_1): lock_4[column_1-1-x][y]=lock_3[row_1 -1- y][column_1-1-x]=lock_2[x...原创 2018-11-04 15:28:33 · 184 阅读 · 0 评论 -
Reverse Roman Numerals[romnan dict]
猥琐法def reverse_roman(roman_string): #replace this for solution for x in range(4000): if checkio(x)==roman_string: return x elements = { 1000 : 'M', 900 : 'CM', 500 ...原创 2018-11-09 11:47:04 · 136 阅读 · 0 评论 -
Largest Rectangle in a Histogram[]
思路: 按照 高 从1到max(histogram) 逐次查找最大面积高为1 时…高为2 时……# Largest Rectangle in a Histogram# def largest_histogram(histogram): max_area=max(histogram) for x in range(1,max(histogram)): ...原创 2018-11-09 11:21:27 · 305 阅读 · 0 评论 -
The Secret Room [英文数字 ]
思路: 用字典创建 数字:英文 键值对 然后分类处理number_constant = {0:"", 1:"one", 2:"two", 3:"three", 4:"four", 5:"five", 6:"six", 7:"seven&原创 2018-11-03 23:28:20 · 281 阅读 · 0 评论 -
Wild Dogs [直线 count 有效数字]
思路: 方程 y = k * x + b 距离def wild_dogs(coords): # 所有点 22 得到 (k, b) list_1=[] for x_1, y_1 in coords: for x_2, y_2 in coords: if x_1!= x_2: k=(y_2- y_1...原创 2018-11-03 21:57:09 · 172 阅读 · 0 评论 -
Compass, Map and Spyglass [ ]
思路: (x, y)坐标之差的最大值为 最短路径def navigation(seaside): #replace this for solution column_1=len(seaside[0]) row_1=len(seaside) for x in range(row_1): for y in range(column_1): ...原创 2018-11-03 18:56:15 · 388 阅读 · 0 评论 -
Ground for the House[去掉行列]
把每一行是纯0的去掉,就是了def house(plan): #replace this for solution if '#'not in plan:return 0 str_1=plan.split() column_1 =len(str_1) row_1 = len(str_1[0]) column_min=100 colum...原创 2018-11-03 18:53:35 · 177 阅读 · 0 评论 -
Common Words [set 集合 ]
解法:借用 set 进行集合交运算, 先转换为列表, 再换为集合, 进行交, 再换为列表, 排序, 换为字符串.# Common Wordsdef checkio(first, second): return ','.join(sorted(list(set(first.split(','))&amp;amp;set(second.split(',')))))#These &quot;assert...原创 2018-10-25 23:16:25 · 341 阅读 · 0 评论 -
Three Words [isalpha() 字母]
思路:# Three Words# def checkio(words: str) -&gt; bool: words=(words.split()) count_1=0 for x in words: if x.isalpha(): count_1+=1 else: count_1=0...原创 2018-11-04 23:12:18 · 240 阅读 · 0 评论