aboutsummaryrefslogtreecommitdiff
path: root/challenge-040/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
authordrclaw1394 <drclaw@mac.com>2019-12-26 13:03:51 +1000
committerGitHub <noreply@github.com>2019-12-26 13:03:51 +1000
commit680c45532e49d93c882dc062d9c7394ce8ddac31 (patch)
tree323459288c4d58e1a94f4f1e2d1ccaff39993238 /challenge-040/lubos-kolouch/python/ch-2.py
parentc3497f2ab3d29d8578be2f238823f0c25ee9d489 (diff)
parent8197e767f4477a114b1a25e77cb277d58c621102 (diff)
downloadperlweeklychallenge-club-680c45532e49d93c882dc062d9c7394ce8ddac31.tar.gz
perlweeklychallenge-club-680c45532e49d93c882dc062d9c7394ce8ddac31.tar.bz2
perlweeklychallenge-club-680c45532e49d93c882dc062d9c7394ce8ddac31.zip
Merge pull request #39 from manwar/master
Update to w40
Diffstat (limited to 'challenge-040/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-040/lubos-kolouch/python/ch-2.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-040/lubos-kolouch/python/ch-2.py b/challenge-040/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..3c0a6706bb
--- /dev/null
+++ b/challenge-040/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,29 @@
+#!python3
+
+import numpy as np
+import sys
+
+# python ch-2.py "[ 10, 4, 1, 8, 12, 3 ][ 0, 2, 5 ]"
+
+assert len(sys.argv) == 2
+
+arr1 = np.empty(0, int)
+arr2 = np.empty(0, int)
+arr = np.array(sys.argv[1].replace('[', '').replace(' ', '').split(']'))
+
+arr1 = arr[0].split(',')
+arr2 = arr[1].split(',')
+
+arr_sort = np.empty(0, int)
+
+for key in arr2:
+ arr_sort = np.append(arr_sort, int(arr1[int(key)]))
+
+arr_sort = np.sort(arr_sort)
+
+i = -1
+for key in arr2:
+ i += 1
+ arr1[int(key)] = arr_sort[i]
+
+print(arr1)