Skip to content

Commit 1b36d6f

Browse files
committed
add practice
1 parent 20a300d commit 1b36d6f

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

python/index.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ def replaceDigits(s: str) -> str:
267267
# Output: "abcdef"
268268
# print(replaceDigits(s))
269269

270-
271-
a = [12,6,3]
272-
b = map(str,a)
273-
print(list(b))
270+
def startswith(w):
271+
return w.startswith("a")
272+
li = ['apple','orange','pineapple','grape']
273+
res = filter(startswith,li)
274+
print(list(res))

python/leetcode/math/1925:.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from math import sqrt
2+
class So:
3+
'''
4+
So 的 Docstring
5+
6+
'''
7+
def countTriples(self, n: int) -> int:
8+
'''
9+
1925. Count Square Sum Triples
10+
11+
triple = a 二次方 + b 二次方 = c 二次方
12+
13+
:param self: 說明
14+
:param n: 數值n
15+
:type n: int
16+
:return: 說明
17+
:rtype: int
18+
'''
19+
ans = 0
20+
for a in range(1,n + 1):
21+
for b in range(1,n + 1):
22+
pairs = int(sqrt(a**2 + b**2 + 1))
23+
if pairs <= n and pairs **2 == a**2 + b**2:
24+
ans += 1
25+
return ans
26+
27+
ans = So()
28+
n = 5
29+
# 2
30+
print(ans.countTriples(n))

0 commit comments

Comments
 (0)