aboutsummaryrefslogtreecommitdiff
path: root/challenge-216/robert-dicicco/python/ch-1.py
blob: 1e3344bd907e30cb0b59bc6d139cb1a4afee6b6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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']
# ------------------------------------------