aboutsummaryrefslogtreecommitdiff
path: root/challenge-185
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-10-03 20:18:29 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-10-03 20:18:29 +0100
commit904d0fc37eefa8657eeadb442df1b3bbe6dec77f (patch)
tree9106374329bfabf78fd8978878f7068f1e349bff /challenge-185
parent0b2511c8c4785640d7463239afc774f126a9ce68 (diff)
downloadperlweeklychallenge-club-904d0fc37eefa8657eeadb442df1b3bbe6dec77f.tar.gz
perlweeklychallenge-club-904d0fc37eefa8657eeadb442df1b3bbe6dec77f.tar.bz2
perlweeklychallenge-club-904d0fc37eefa8657eeadb442df1b3bbe6dec77f.zip
- Added guest contributions by Eric Cheung.
Diffstat (limited to 'challenge-185')
-rwxr-xr-xchallenge-185/eric-cheung/python/ch-1.py14
-rwxr-xr-xchallenge-185/eric-cheung/python/ch-2.py23
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-185/eric-cheung/python/ch-1.py b/challenge-185/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..bd155daa2e
--- /dev/null
+++ b/challenge-185/eric-cheung/python/ch-1.py
@@ -0,0 +1,14 @@
+
+## Task 1: MAC Address
+## Input Format: hhhh.hhhh.hhhh
+## Output Format: hh:hh:hh:hh:hh:hh
+
+## strInputMACAddr = "1ac2.34f0.b1c2" ## Example 1
+strInputMACAddr = "abc1.20f1.345a" ## Example 2
+
+strNoSplit = strInputMACAddr.replace(".", "")
+arrPartSplit = [strNoSplit[nIndx] + strNoSplit[nIndx + 1] for nIndx in range(0, len(strNoSplit), 2)]
+
+strOutputMACAddr = ":".join(arrPartSplit)
+
+print (strOutputMACAddr)
diff --git a/challenge-185/eric-cheung/python/ch-2.py b/challenge-185/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..54f39f2974
--- /dev/null
+++ b/challenge-185/eric-cheung/python/ch-2.py
@@ -0,0 +1,23 @@
+
+## arrListInput = ['ab-cde-123', '123.abc.420', '3abc-0010.xy'] ## Example 1
+arrListInput = ['1234567.a', 'a-1234-bc', 'a.b.c.d.e.f'] ## Example 2
+
+arrListOutput = []
+nMaxToMask = 4
+
+for strLoop in arrListInput:
+
+ strResult = ""
+ nMaskCount = 0
+
+ for charLoop in strLoop:
+
+ if charLoop.isalnum() and nMaskCount < nMaxToMask:
+ strResult = strResult + "x"
+ nMaskCount = nMaskCount + 1
+ else:
+ strResult = strResult + charLoop
+
+ arrListOutput.append(strResult)
+
+print (arrListOutput)