diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-06 11:19:31 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-06 11:19:31 +0100 |
| commit | 479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde (patch) | |
| tree | a833604c9880a15ef297b9f9378d333f7018160e /challenge-268/eric-cheung/python/ch-2.py | |
| parent | 2613c50fbf02be26a82bb14a464fa61d2afc23ac (diff) | |
| download | perlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.tar.gz perlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.tar.bz2 perlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Mark Anderson.
- Added solutions by Feng Chang.
- Added solutions by PokGoPun.
Diffstat (limited to 'challenge-268/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-268/eric-cheung/python/ch-2.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-268/eric-cheung/python/ch-2.py b/challenge-268/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..de091f76fe --- /dev/null +++ b/challenge-268/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ +
+## arrInt = [2, 5, 3, 4] ## Example 1
+## arrInt = [9, 4, 1, 3, 6, 4, 6, 1] ## Example 2
+arrInt = [1, 2, 2, 3] ## Example 3
+
+arrInt = sorted(arrInt)
+arrOutput = []
+
+while len(arrInt) > 0:
+ arrOutput.append(arrInt[1])
+ arrOutput.append(arrInt[0])
+ del arrInt[1]
+ del arrInt[0]
+
+print (arrOutput)
|
