aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-262/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-262/lubos-kolouch/python/ch-2.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-262/lubos-kolouch/python/ch-2.py b/challenge-262/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..5d42adf2a0
--- /dev/null
+++ b/challenge-262/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,16 @@
+from typing import List
+
+
+def count_equal_divisible(ints: List[int], k: int) -> int:
+ count = 0
+ n = len(ints)
+ for i in range(n):
+ for j in range(i + 1, n):
+ if ints[i] == ints[j] and i * j % k == 0:
+ count += 1
+ return count
+
+
+# Assert tests
+assert count_equal_divisible([3, 1, 2, 2, 2, 1, 3], 2) == 4
+assert count_equal_divisible([1, 2, 3], 1) == 0