摘要: C语言 #sscanf #代码学习 #codewars 题目链接:IP Validation | Codewars 代码如下: #include <stdio.h> int is_valid_ip(const char *addr) { unsigned n[4], i, nc; // Must b 阅读全文
posted @ 2024-02-06 21:01 Kazuma_124 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.codewars.com/kata/5426d7a2c2c7784365000783/python def balanced_parens(n): ''' To construct all the possible strings with n pairs of b 阅读全文
posted @ 2024-02-06 11:41 Kazuma_124 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.codewars.com/kata/5426d7a2c2c7784365000783/python 我的解决方案: def balanced_parens(n): # Your code here! used_l=[False for i in range(n)] 阅读全文
posted @ 2024-02-05 14:26 Kazuma_124 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 题目的要求是写一个Sudoku类,类中要有一个实例函数判断传给对象的二维数组是否符合数独规则 题目链接:https://www.codewars.com/kata/540afbe2dc9f615d5e000425/python 下面是写完题后看到的别人的解决方法 from itertools imp 阅读全文
posted @ 2024-02-03 19:09 Kazuma_124 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 做题的时候有的测试点里竟然用True替换1,骗过了我的代码,结果没过测试点 lst = [1, True] for item in lst: if not isinstance(item, bool) and item == 1: print(item) 阅读全文
posted @ 2024-02-02 22:09 Kazuma_124 阅读(6) 评论(0) 推荐(0) 编辑
摘要: def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a 阅读全文
posted @ 2024-01-29 17:38 Kazuma_124 阅读(8) 评论(0) 推荐(0) 编辑
摘要: class pers(): def __init__(self,hp): self._hp=hp @property def hp(self): return self._hp @hp.setter def hp(self,hp): self._hp=gp if hp>=0 else 0 a=per 阅读全文
posted @ 2024-01-27 16:09 Kazuma_124 阅读(15) 评论(0) 推荐(0) 编辑
摘要: class test(): aaa = 111 bbb = 222 ccc = 333 @classmethod def cm(cls): cls.aaa="***" def im(self): self.aaa="iii" aa = test() print(aa.aaa,aa.bbb,aa.cc 阅读全文
posted @ 2024-01-27 15:11 Kazuma_124 阅读(18) 评论(0) 推荐(0) 编辑
摘要: t = ([1,2,3],[2,3,4],3) print(t) t[0][1]=9 print(t) # ~ t[2]=9#TypeError: 'tuple' object does not support item assignment # ~ print(t) ''' ([1, 2, 3], 阅读全文
posted @ 2024-01-18 16:24 Kazuma_124 阅读(9) 评论(0) 推荐(0) 编辑
摘要: m = 10 a = 10 print(id(m)) print(id(a)) '''输出 140713874176728 140713874176728 ''' print() a = 1 b = 2 c = 3 d = a+b print('a(1)\t'+str(id(a))) print(' 阅读全文
posted @ 2024-01-18 12:06 Kazuma_124 阅读(12) 评论(0) 推荐(0) 编辑