aboutsummaryrefslogtreecommitdiff
path: root/challenge-277/sgreen/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-277/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-277/sgreen/python/ch-2.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-277/sgreen/python/ch-2.py b/challenge-277/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..7896268051
--- /dev/null
+++ b/challenge-277/sgreen/python/ch-2.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def strong_pair(ints: list) -> int:
+ # Remove duplicates
+ ints = list(set(ints))
+ count = 0
+
+ for i in range(len(ints)-1):
+ for j in range(i+1, len(ints)):
+ if abs(ints[i]-ints[j]) < min(ints[i], ints[j]):
+ count += 1
+
+ return count
+
+
+def main():
+ # Convert input into integers
+ array = [int(n) for n in sys.argv[1:]]
+ result = strong_pair(array)
+ print(result)
+
+
+if __name__ == '__main__':
+ main()