aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/zapwai/python
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-03-25 09:49:00 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-03-25 09:49:00 -0400
commit19f63fc58c320d068d069868282a77f14989b2cc (patch)
treecc55185deabd008ed48b894a6ba7335069ba7fae /challenge-262/zapwai/python
parent041fe9129e3ef4d86df461a0feeee1b3740d5758 (diff)
downloadperlweeklychallenge-club-19f63fc58c320d068d069868282a77f14989b2cc.tar.gz
perlweeklychallenge-club-19f63fc58c320d068d069868282a77f14989b2cc.tar.bz2
perlweeklychallenge-club-19f63fc58c320d068d069868282a77f14989b2cc.zip
Week 262
Diffstat (limited to 'challenge-262/zapwai/python')
-rw-r--r--challenge-262/zapwai/python/ch-1.py13
-rw-r--r--challenge-262/zapwai/python/ch-2.py11
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-262/zapwai/python/ch-1.py b/challenge-262/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..d3354b4a69
--- /dev/null
+++ b/challenge-262/zapwai/python/ch-1.py
@@ -0,0 +1,13 @@
+ints = [-3, 1, 2, -1, 3, -2, 4]
+print("Input:", ints)
+neg = 0
+pos = 0
+for num in ints:
+ if num < 0:
+ if neg > num:
+ neg = num
+ else:
+ if pos < num:
+ pos = num
+ans = max(abs(neg), pos)
+print("Output:", ans)
diff --git a/challenge-262/zapwai/python/ch-2.py b/challenge-262/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..a78b532467
--- /dev/null
+++ b/challenge-262/zapwai/python/ch-2.py
@@ -0,0 +1,11 @@
+ints = [3, 1, 2, 2, 2, 1, 3]
+k = 2
+print("Input: ints:", ints, "k:", k)
+cnt = 0
+for i in range(len(ints) - 1):
+ for j in range(i + 1, len(ints)):
+ if ints[i] != ints[j]:
+ continue
+ if i * j % k == 0:
+ cnt += 1
+print("Output:", cnt)