aboutsummaryrefslogtreecommitdiff
path: root/challenge-269/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-269/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-269/eric-cheung/python/ch-2.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-269/eric-cheung/python/ch-2.py b/challenge-269/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..bb95583826
--- /dev/null
+++ b/challenge-269/eric-cheung/python/ch-2.py
@@ -0,0 +1,15 @@
+
+## arrInt = [2, 1, 3, 4, 5] ## Example 1
+## arrInt = [3, 2, 4] ## Example 2
+arrInt = [5, 4, 3 ,8] ## Example 3
+
+arrOut_01 = [arrInt[0]]
+arrOut_02 = [arrInt[1]]
+
+for nLoop in arrInt[2:]:
+ if arrOut_01[-1] > arrOut_02[-1]:
+ arrOut_01.append(nLoop)
+ else:
+ arrOut_02.append(nLoop)
+
+print (arrOut_01 + arrOut_02)