aboutsummaryrefslogtreecommitdiff
path: root/challenge-074/walt-mankowski/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-074/walt-mankowski/python/ch-2.py')
-rw-r--r--challenge-074/walt-mankowski/python/ch-2.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-074/walt-mankowski/python/ch-2.py b/challenge-074/walt-mankowski/python/ch-2.py
new file mode 100644
index 0000000000..1c1d4e1609
--- /dev/null
+++ b/challenge-074/walt-mankowski/python/ch-2.py
@@ -0,0 +1,21 @@
+from sys import argv
+
+s = argv[1]
+seen = set()
+nr = []
+out = []
+
+for c in s:
+ # have we seen c before?
+ if c not in seen:
+ # add c to nr
+ seen.add(c)
+ nr.append(c)
+ else:
+ # remove c from nr
+ nr.remove(c)
+
+ # now the FNR is either the last element of nr, or #
+ out.append(nr[-1] if nr else '#')
+
+print(''.join(out))