aboutsummaryrefslogtreecommitdiff
path: root/challenge-249/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-249/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-249/eric-cheung/python/ch-1.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-249/eric-cheung/python/ch-1.py b/challenge-249/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..e41155cc52
--- /dev/null
+++ b/challenge-249/eric-cheung/python/ch-1.py
@@ -0,0 +1,16 @@
+
+arrInt = [3, 2, 3, 2, 2, 2] ## Example 1
+## arrInt = [1, 2, 3, 4] ## Example 2
+
+arrUniq = list(set(arrInt))
+arrCount = [arrInt.count(nLoop) for nLoop in arrUniq]
+arrOutput = []
+
+if any(nLoop % 2 == 1 for nLoop in arrCount):
+ print ([])
+else:
+ for nIndx in range(len(arrUniq)):
+ for nCount in range(int(arrCount[nIndx] / 2)):
+ arrOutput.append([arrUniq[nIndx], arrUniq[nIndx]])
+
+ print (arrOutput)