aboutsummaryrefslogtreecommitdiff
path: root/challenge-306/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-306/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-306/eric-cheung/python/ch-2.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-306/eric-cheung/python/ch-2.py b/challenge-306/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..71a2f127a8
--- /dev/null
+++ b/challenge-306/eric-cheung/python/ch-2.py
@@ -0,0 +1,18 @@
+
+## arrInts = [3, 8, 5, 2, 9, 2] ## Example 1
+arrInts = [3, 2, 5] ## Example 2
+
+while len(arrInts) > 1:
+ arrInts = sorted(arrInts)
+
+ nY = arrInts[-1]
+ nX = arrInts[-2]
+
+ del arrInts[-2]
+ del arrInts[-1]
+
+ if nY > nX:
+ arrInts.append(nY - nX)
+
+print (0 if len(arrInts) == 0 else arrInts[0])
+