aboutsummaryrefslogtreecommitdiff
path: root/challenge-284/eric-cheung/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-284/eric-cheung/python')
-rwxr-xr-xchallenge-284/eric-cheung/python/ch-1.py11
-rwxr-xr-xchallenge-284/eric-cheung/python/ch-2.py24
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-284/eric-cheung/python/ch-1.py b/challenge-284/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..a692fad3bf
--- /dev/null
+++ b/challenge-284/eric-cheung/python/ch-1.py
@@ -0,0 +1,11 @@
+
+## arrInts = [2, 2, 3, 4] ## Example 1
+## arrInts = [1, 2, 2, 3, 3, 3] ## Example 2
+arrInts = [1, 1, 1, 3] ## Example 3
+
+arrLucky = [nLoop for nLoop in set(arrInts) if arrInts.count(nLoop) == nLoop]
+
+if len(arrLucky) == 0:
+ print (-1)
+else:
+ print (max(arrLucky))
diff --git a/challenge-284/eric-cheung/python/ch-2.py b/challenge-284/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..9230393f83
--- /dev/null
+++ b/challenge-284/eric-cheung/python/ch-2.py
@@ -0,0 +1,24 @@
+
+## Example 1
+## arrList_01 = [2, 3, 9, 3, 1, 4, 6, 7, 2, 8, 5]
+## arrList_02 = [2, 1, 4, 3, 5, 6]
+
+## Example 2
+## arrList_01 = [3, 3, 4, 6, 2, 4, 2, 1, 3]
+## arrList_02 = [1, 3, 2]
+
+## Example 3
+arrList_01 = [3, 0, 5, 0, 2, 1, 4, 1, 1]
+arrList_02 = [1, 0, 3, 2]
+
+arrOutput = []
+
+## Contain
+for nLoop in arrList_02:
+ arrOutput = arrOutput + [nLoop] * arrList_01.count(nLoop)
+
+## Miss
+for nLoop in [rLoop for rLoop in set(arrList_01) if rLoop not in arrList_02]:
+ arrOutput = arrOutput + [nLoop] * arrList_01.count(nLoop)
+
+print (arrOutput)