From 7aff3f0a8f31701a7c8927fcbc41a9a194e4a157 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 22 Jul 2024 09:41:47 +0100 Subject: - Added solutions by Eric Cheung. --- challenge-279/eric-cheung/python/ch-1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 challenge-279/eric-cheung/python/ch-1.py (limited to 'challenge-279/eric-cheung/python/ch-1.py') diff --git a/challenge-279/eric-cheung/python/ch-1.py b/challenge-279/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..50d0bbbc82 --- /dev/null +++ b/challenge-279/eric-cheung/python/ch-1.py @@ -0,0 +1,18 @@ + +## Example 1 +## arrLetters = ["R", "E", "P", "L"] +## arrWeights = [3, 2, 1, 4] + +## Example 2 +## arrLetters = ["A", "U", "R", "K"] +## arrWeights = [2, 4, 1, 3] + +## Example 3 +arrLetters = ["O", "H", "Y", "N", "P", "T"] +arrWeights = [5, 4, 2, 6, 1, 3] + +arrSort = sorted([[nWeightLoop, charLoop] for charLoop, nWeightLoop in zip(arrLetters, arrWeights)]) + +strOutput = "".join([charLoop for nWeightLoop, charLoop in arrSort]) + +print (strOutput) -- cgit