aboutsummaryrefslogtreecommitdiff
path: root/challenge-338/sgreen/python/ch-2.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2025-09-14 22:54:18 +1000
committerSimon Green <mail@simon.green>2025-09-14 22:54:18 +1000
commit045da04e63323acdfffc3d1a0cd92bf0853364b0 (patch)
tree643f80cc8f66f05500e94db273ea9faf700636b8 /challenge-338/sgreen/python/ch-2.py
parent12d9b7370121f12b601562856772ed3c03f7bb94 (diff)
downloadperlweeklychallenge-club-045da04e63323acdfffc3d1a0cd92bf0853364b0.tar.gz
perlweeklychallenge-club-045da04e63323acdfffc3d1a0cd92bf0853364b0.tar.bz2
perlweeklychallenge-club-045da04e63323acdfffc3d1a0cd92bf0853364b0.zip
sgreen solutions to challenge 338
Diffstat (limited to 'challenge-338/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-338/sgreen/python/ch-2.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-338/sgreen/python/ch-2.py b/challenge-338/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..10dfb99729
--- /dev/null
+++ b/challenge-338/sgreen/python/ch-2.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+
+
+def max_distance(arr1: list[int], arr2: list[int]) -> int:
+ """Return the highest distance between any two integers in the lists.
+
+ Args:
+ arr1: A list of integers.
+ arr2: A list of integers.
+
+ Returns:
+ The highest distance between any two integers in the lists.
+ """
+ return max(abs(a - b) for a in arr1 for b in arr2)
+
+
+def main():
+ # Convert input into integers.
+ arr1 = [int(n) for n in re.split(r'\D+', sys.argv[1])]
+ arr2 = [int(n) for n in re.split(r'\D+', sys.argv[2])]
+ result = max_distance(arr1, arr2)
+ print(result)
+
+
+if __name__ == '__main__':
+ main()