From 19f63fc58c320d068d069868282a77f14989b2cc Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Mon, 25 Mar 2024 09:49:00 -0400 Subject: Week 262 --- challenge-262/zapwai/python/ch-1.py | 13 +++++++++++++ challenge-262/zapwai/python/ch-2.py | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 challenge-262/zapwai/python/ch-1.py create mode 100644 challenge-262/zapwai/python/ch-2.py (limited to 'challenge-262/zapwai/python') 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) -- cgit