From 62f1ccaddfc5a65501df9cfdf528d28927fef410 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 12 May 2025 05:47:55 +0100 Subject: - Added template for week 321. --- challenge-321/eric-cheung/README | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-321/eric-cheung/README (limited to 'challenge-321/eric-cheung') diff --git a/challenge-321/eric-cheung/README b/challenge-321/eric-cheung/README new file mode 100644 index 0000000000..1bf6db4498 --- /dev/null +++ b/challenge-321/eric-cheung/README @@ -0,0 +1 @@ +Solutions by Eric Cheung. -- cgit From a799bc96049a853dae3a0b8bf14c4eb581a4a4ba Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Tue, 13 May 2025 13:30:54 +0100 Subject: - 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. --- challenge-321/eric-cheung/python/ch-1.py | 19 +++++++++++++++++++ challenge-321/eric-cheung/python/ch-2.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 challenge-321/eric-cheung/python/ch-1.py create mode 100755 challenge-321/eric-cheung/python/ch-2.py (limited to 'challenge-321/eric-cheung') 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))) diff --git a/challenge-321/eric-cheung/python/ch-2.py b/challenge-321/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..092cd5378f --- /dev/null +++ b/challenge-321/eric-cheung/python/ch-2.py @@ -0,0 +1,29 @@ + +def GetRefineStr (strInput): + arrTemp = list(strInput) + while "#" in arrTemp: + nPosBackSpace = arrTemp.index("#") + arrTemp.pop(nPosBackSpace) + arrTemp.pop(nPosBackSpace - 1) + + return "".join(arrTemp) + +## Example 1 +## strInput_01 = "ab#c" +## strInput_02 = "ad#c" + +## Example 2 +## strInput_01 = "ab##" +## strInput_02 = "a#b#" + +## Example 3 +strInput_01 = "a#b" +strInput_02 = "c" + +strInput_01_rev = GetRefineStr(strInput_01) +strInput_02_rev = GetRefineStr(strInput_02) + +## print (strInput_01_rev) +## print (strInput_02_rev) + +print (strInput_01_rev == strInput_02_rev) -- cgit