aboutsummaryrefslogtreecommitdiff
path: root/challenge-243/e-choroba/python
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-11-20 15:40:49 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-11-20 15:40:49 +0800
commit72dc5412e640e26601ffdebc4f0247db4c4bc7fe (patch)
treed405aa98925dfed0b745e5ec331e9498005b1de7 /challenge-243/e-choroba/python
parent35d79358f3d12607da66ffefefed5e93c469d396 (diff)
parentfda51162ad0e1e8b4489fd2c73ef7dfdc8f0df5e (diff)
downloadperlweeklychallenge-club-72dc5412e640e26601ffdebc4f0247db4c4bc7fe.tar.gz
perlweeklychallenge-club-72dc5412e640e26601ffdebc4f0247db4c4bc7fe.tar.bz2
perlweeklychallenge-club-72dc5412e640e26601ffdebc4f0247db4c4bc7fe.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-243/e-choroba/python')
-rwxr-xr-xchallenge-243/e-choroba/python/ch-1.py12
-rwxr-xr-xchallenge-243/e-choroba/python/ch-2.py7
2 files changed, 19 insertions, 0 deletions
diff --git a/challenge-243/e-choroba/python/ch-1.py b/challenge-243/e-choroba/python/ch-1.py
new file mode 100755
index 0000000000..7ed59ec981
--- /dev/null
+++ b/challenge-243/e-choroba/python/ch-1.py
@@ -0,0 +1,12 @@
+#!/usr/bin/python3
+def reverse_pairs(*nums: int) -> int:
+ tally = 0
+ for j in range(1, len(nums)):
+ for i in range(0, j):
+ if nums[i] > 2 * nums[j]:
+ tally += 1
+ return tally
+
+assert reverse_pairs(1, 3, 2, 3, 1) == 2
+assert reverse_pairs(2, 4, 3, 5, 1) == 3
+
diff --git a/challenge-243/e-choroba/python/ch-2.py b/challenge-243/e-choroba/python/ch-2.py
new file mode 100755
index 0000000000..77e9ab82cf
--- /dev/null
+++ b/challenge-243/e-choroba/python/ch-2.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python3
+from math import floor
+def floor_sum(*nums: int) -> int:
+ return sum([floor(i / j) for i in nums for j in nums])
+
+assert floor_sum(2, 5, 9) == 10
+assert floor_sum(7, 7, 7, 7, 7, 7, 7) == 49