aboutsummaryrefslogtreecommitdiff
path: root/challenge-216/robert-dicicco/python
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2023-05-10 17:09:33 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2023-05-10 17:09:33 +0100
commitbb52405967e3387c63e9fffd0a2bd82678882f40 (patch)
tree88eba058d26136d2a86dcc77982f42cdc245bdf6 /challenge-216/robert-dicicco/python
parent2e943784a5c321b375ba33ab415a70dcf030b61c (diff)
parent722527ed475e56e5717e60f8d3b52d9bbcef492c (diff)
downloadperlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.tar.gz
perlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.tar.bz2
perlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-216/robert-dicicco/python')
-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']
+# ------------------------------------------
+
+
+
+