aboutsummaryrefslogtreecommitdiff
path: root/challenge-195/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-12-13 12:30:19 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-12-13 12:30:19 +0000
commitfefc7c358edfe567b1444cb88caed7738c4eb4fe (patch)
tree84a80c331f7abe024b47f1b87259da2bbd4380c3 /challenge-195/eric-cheung/python
parent8fbb6f0e0ee5a71153e0292c21a053b183342fe8 (diff)
downloadperlweeklychallenge-club-fefc7c358edfe567b1444cb88caed7738c4eb4fe.tar.gz
perlweeklychallenge-club-fefc7c358edfe567b1444cb88caed7738c4eb4fe.tar.bz2
perlweeklychallenge-club-fefc7c358edfe567b1444cb88caed7738c4eb4fe.zip
- Added solutions by Luca Ferrari.
- Added solutions by David Ferrone. - Added solutions by Dave Jacoby. - Added solutions by Mark Anderson. - Added solutions by Thomas Kohler. - Added solutions by Robert Ransbottom. - Added solutions by W. Luis Mochan. - Added solutions by Ulrich Rieke. - Added solutions by Olivier Delouya. - Added solutions by Robert DiCicco.
Diffstat (limited to 'challenge-195/eric-cheung/python')
-rwxr-xr-xchallenge-195/eric-cheung/python/ch-1.py30
-rwxr-xr-xchallenge-195/eric-cheung/python/ch-2.py20
2 files changed, 50 insertions, 0 deletions
diff --git a/challenge-195/eric-cheung/python/ch-1.py b/challenge-195/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..4839f6f0fc
--- /dev/null
+++ b/challenge-195/eric-cheung/python/ch-1.py
@@ -0,0 +1,30 @@
+
+def IsNumSpecial(nInput):
+
+ if nInput < 11:
+ return True
+
+ arrList = list(map(int, str(nInput)))
+ arrUniqList = list(set(arrList))
+
+ for nLoop in arrUniqList:
+ if arrList.count(nLoop) > 1:
+ return False
+
+ return True
+
+def nCountNumSpecial(nNum):
+
+ arrOutputList = []
+
+ for nVar in range(1, nNum + 1):
+ if IsNumSpecial(nVar):
+ arrOutputList.append(nVar)
+
+ return len(arrOutputList)
+
+
+## nGivenInput = 15 ## Example 1
+nGivenInput = 35 ## Example 2
+
+print (nCountNumSpecial(nGivenInput))
diff --git a/challenge-195/eric-cheung/python/ch-2.py b/challenge-195/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..b141abef13
--- /dev/null
+++ b/challenge-195/eric-cheung/python/ch-2.py
@@ -0,0 +1,20 @@
+
+nArrList = [1, 1, 2, 6, 2] ## Example 1
+## nArrList = [1, 3, 5, 7] ## Example 2
+## nArrList = [6, 4, 4, 6, 1] ## Example 3
+
+nArrEvenList = [nLoop for nLoop in nArrList if nLoop % 2 == 0]
+nArrUniqEvenList = list(set(nArrEvenList))
+
+nSmallEvenNum = -1
+nEvenNumCount = 0
+
+for nLoop in nArrUniqEvenList:
+
+ nCount = nArrEvenList.count(nLoop)
+
+ if nCount > nEvenNumCount and (nLoop < nSmallEvenNum or nSmallEvenNum < 0):
+ nSmallEvenNum = nLoop
+ nEvenNumCount = nCount
+
+print (nSmallEvenNum)