From dd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Tue, 16 Jul 2024 11:53:17 +0100 Subject: - Added solutions by Eric Cheung. - Added solutions by Laurent Rosenfeld. - Added solutions by Mark Anderson. - Added solutions by Alexander Karelas. - Added solutions by Matthew Neleigh. - Added solutions by Feng Chang. - Added solutions by E. Choroba. - Added solutions by PokGoPun. - Added solutions by Steven Wilson. - Added solutions by Peter Meszaros. - Added solutions by Peter Campbell Smith. - Added solutions by David Ferrone. - Added solutions by Conor Hoekstra. - Added solutions by Thomas Kohler. - Added solutions by W. Luis Mochan. - Added solutions by Jaldhar H. Vyas. - Added solutions by Athanasius. - Added solutions by Robbie Hatley. - Added solutions by Luca Ferrari. --- challenge-278/eric-cheung/python/ch-1.py | 10 ++++++++++ challenge-278/eric-cheung/python/ch-2.py | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 challenge-278/eric-cheung/python/ch-1.py create mode 100755 challenge-278/eric-cheung/python/ch-2.py (limited to 'challenge-278/eric-cheung/python') diff --git a/challenge-278/eric-cheung/python/ch-1.py b/challenge-278/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..5fd86d7d26 --- /dev/null +++ b/challenge-278/eric-cheung/python/ch-1.py @@ -0,0 +1,10 @@ + +## strShuffle = "and2 Raku3 cousins5 Perl1 are4" ## Example 1 +## strShuffle = "guest6 Python1 most4 the3 popular5 is2 language7" ## Example 2 +strShuffle = "Challenge3 The1 Weekly2" ## Example 3 + +arrSplit = sorted([[int(strLoop[-1]), strLoop[:-1]] for strLoop in strShuffle.split()]) + +arrOrder = [strSortLoop for nSort, strSortLoop in arrSplit] + +print (" ".join(arrOrder)) diff --git a/challenge-278/eric-cheung/python/ch-2.py b/challenge-278/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..e173d974d8 --- /dev/null +++ b/challenge-278/eric-cheung/python/ch-2.py @@ -0,0 +1,18 @@ + +## Example 1 +## strInput = "challenge" +## charInput = "e" + +## Example 2 +## strInput = "programming" +## charInput = "a" + +## Example 3 +strInput = "champion" +charInput = "b" + +if charInput in strInput: + nPos = strInput.find(charInput) + print ("".join(sorted(strInput[:nPos + 1])) + strInput[nPos + 1:]) +else: + print (strInput) -- cgit