aboutsummaryrefslogtreecommitdiff
path: root/challenge-180/deadmarshal/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-180/deadmarshal/python')
-rw-r--r--challenge-180/deadmarshal/python/ch1.py20
-rw-r--r--challenge-180/deadmarshal/python/ch2.py9
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-180/deadmarshal/python/ch1.py b/challenge-180/deadmarshal/python/ch1.py
new file mode 100644
index 0000000000..a006f46cb3
--- /dev/null
+++ b/challenge-180/deadmarshal/python/ch1.py
@@ -0,0 +1,20 @@
+import sys
+
+def first_unique_character(s):
+ freq = {}
+ for i in s:
+ if i not in freq:
+ freq[i] = 1
+ else:
+ freq[i] += 1
+
+ for i in range(len(s)):
+ if(freq[s[i]] == 1):
+ return f"{i} as '{s[i]}' is the first unique character"
+ return -1
+
+if(len(sys.argv) != 2):
+ sys.stderr.write("No arg(s) provided!\n")
+ sys.exit(1)
+
+print(first_unique_character(sys.argv[1]))
diff --git a/challenge-180/deadmarshal/python/ch2.py b/challenge-180/deadmarshal/python/ch2.py
new file mode 100644
index 0000000000..7522545459
--- /dev/null
+++ b/challenge-180/deadmarshal/python/ch2.py
@@ -0,0 +1,9 @@
+def trim_list(arr, i):
+ return list(filter(lambda x: x > i, arr))
+
+i,i2 = 3, 4
+n = [1,4,2,3,5]
+n2 = [9,0,6,2,3,8,5]
+
+print(trim_list(n, i))
+print(trim_list(n2, i2))