diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-05-13 13:30:54 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-05-13 13:30:54 +0100 |
| commit | a799bc96049a853dae3a0b8bf14c4eb581a4a4ba (patch) | |
| tree | 129fea9bbf713c223e3ad23f6b43ef3a17397340 /challenge-321/eric-cheung/python/ch-1.py | |
| parent | 152c0ffaaa3df8dfa2a5dbff97971ec378999b0a (diff) | |
| download | perlweeklychallenge-club-a799bc96049a853dae3a0b8bf14c4eb581a4a4ba.tar.gz perlweeklychallenge-club-a799bc96049a853dae3a0b8bf14c4eb581a4a4ba.tar.bz2 perlweeklychallenge-club-a799bc96049a853dae3a0b8bf14c4eb581a4a4ba.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke.
- Added solutions by Mark Anderson.
- Added solutions by Feng Chang.
- Added solutions by E. Choroba.
- Added solutions by Niels van Dijke.
- Added solutions by Andreas Mahnke.
- Added solutions by Luca Ferrari.
- Added solutions by Andrew Shitov.
- Added solutions by Ali Moradi.
- Added solutions by W. Luis Mochan.
- Added solutions by David Ferrone.
- Added solutions by Conor Hoekstra.
- Added solutions by Peter Meszaros.
- Added solutions by Robert Ransbottom.
- Added solutions by Peter Campbell Smith.
- Added solutions by Robbie Hatley.
Diffstat (limited to 'challenge-321/eric-cheung/python/ch-1.py')
| -rwxr-xr-x | challenge-321/eric-cheung/python/ch-1.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-321/eric-cheung/python/ch-1.py b/challenge-321/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..6bd299ac82 --- /dev/null +++ b/challenge-321/eric-cheung/python/ch-1.py @@ -0,0 +1,19 @@ +
+## arrNums = [1, 2, 4, 3, 5, 6] ## Example 1
+## arrNums = [0, 2, 4, 8, 3, 5] ## Example 2
+arrNums = [7, 3, 1, 0, 5, 9] ## Example 3
+
+arrNums = sorted(arrNums)
+
+arrAvg = []
+
+while len(arrNums) > 0:
+ nMax = arrNums[-1]
+ nMin = arrNums[0]
+
+ arrAvg.append((nMax + nMin) / 2)
+
+ arrNums.pop(-1)
+ arrNums.pop(0)
+
+print (len(set(arrAvg)))
|
