aboutsummaryrefslogtreecommitdiff
path: root/challenge-278/eric-cheung/python
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2024-07-16 13:05:06 -0400
committerDave Jacoby <jacoby.david@gmail.com>2024-07-16 13:05:06 -0400
commitf1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6 (patch)
treef601757a365713812e069bd9f49d0ad05046fa41 /challenge-278/eric-cheung/python
parent99b5231db016ad59d74ae19ab4f706dab31e9207 (diff)
parentdd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3 (diff)
downloadperlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.tar.gz
perlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.tar.bz2
perlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
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)