aboutsummaryrefslogtreecommitdiff
path: root/challenge-278/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2024-07-16 11:53:17 +0100
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2024-07-16 11:53:17 +0100
commitdd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3 (patch)
tree3eea20fda4fcbce0072fca2803e037351d0794eb /challenge-278/eric-cheung/python
parentc65f28455c8900599032071d018e679d67cbee1f (diff)
downloadperlweeklychallenge-club-dd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3.tar.gz
perlweeklychallenge-club-dd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3.tar.bz2
perlweeklychallenge-club-dd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3.zip
- 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.
Diffstat (limited to 'challenge-278/eric-cheung/python')
-rwxr-xr-xchallenge-278/eric-cheung/python/ch-1.py10
-rwxr-xr-xchallenge-278/eric-cheung/python/ch-2.py18
2 files changed, 28 insertions, 0 deletions
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)