aboutsummaryrefslogtreecommitdiff
path: root/challenge-216/robert-dicicco/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-216/robert-dicicco/python/ch-1.py')
-rw-r--r--challenge-216/robert-dicicco/python/ch-1.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/challenge-216/robert-dicicco/python/ch-1.py b/challenge-216/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..1e3344bd90
--- /dev/null
+++ b/challenge-216/robert-dicicco/python/ch-1.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# ------------------------------------------
+# AUTHOR: Robert DiCicco
+# DATE : 2023-05-09
+# Challenge 216 Registration Number ( Python )
+# ------------------------------------------
+
+words = [["abc", "abcd", "bcd", "AB1 2CD"], ["job", "james", "bjorg", "007 JB"], ["crack", "road", "rac", "C7 RA2"]]
+out = []
+
+def CheckWords(wd, rg):
+ flag = 0
+ arr = [x for x in rg]
+ for lett in arr:
+ if wd.count(lett) == 0:
+ flag = 1
+ if flag == 0:
+ out.append(wd)
+
+for wds in words:
+ wds_only = wds[0:-1]
+ reg = wds[-1]
+ print("Input: ",wds_only,", $reg = ", reg)
+ reg = reg.translate({ord(i): None for i in '1234567890 '}).lower()
+ x = 0
+ cnt = len(wds) - 1
+ while x < cnt:
+ CheckWords(wds[x],reg)
+ x += 1
+ print("Output: ",out,"\n")
+ out = []
+
+# ------------------------------------------
+# SAMPLE OUTPUT
+# python .\Registration.py
+# Input: ['abc', 'abcd', 'bcd'] , $reg = AB1 2CD
+# Output: ['abcd']
+
+# Input: ['job', 'james', 'bjorg'] , $reg = 007 JB
+# Output: ['job', 'bjorg']
+
+# Input: ['crack', 'road', 'rac'] , $reg = C7 RA2
+# Output: ['crack', 'rac']
+# ------------------------------------------
+
+
+
+