aboutsummaryrefslogtreecommitdiff
path: root/challenge-263/sgreen/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-263/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-263/sgreen/python/ch-1.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-263/sgreen/python/ch-1.py b/challenge-263/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..5f1e0be8fb
--- /dev/null
+++ b/challenge-263/sgreen/python/ch-1.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def target_index(ints: list, k: int) -> list:
+ # Sort the array
+ ints = sorted(ints)
+
+ # Return the indexes where the item is 'k'
+ return [pos for pos, value in enumerate(ints) if value == k]
+
+
+def main():
+ # Convert input into integers
+ array = [int(n) for n in sys.argv[1:]]
+ k = array.pop()
+ result = target_index(array, k)
+ print('(' + ', '.join(map(str, result)) + ')')
+
+
+if __name__ == '__main__':
+ main()