aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-09-05 15:45:54 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-09-05 15:45:54 +0100
commitb6d0223da5058ce5c38d1556f9b3457e5b020739 (patch)
tree0f0d700495709fac1fc024d19e5390d24e180185
parent8ec220688c577ac550baa97ae81397cb72eefdfe (diff)
downloadperlweeklychallenge-club-b6d0223da5058ce5c38d1556f9b3457e5b020739.tar.gz
perlweeklychallenge-club-b6d0223da5058ce5c38d1556f9b3457e5b020739.tar.bz2
perlweeklychallenge-club-b6d0223da5058ce5c38d1556f9b3457e5b020739.zip
- Added guest contributions by Eric Cheung.
-rwxr-xr-xchallenge-181/eric-cheung/python/ch-1.py18
-rwxr-xr-xchallenge-181/eric-cheung/python/ch-2.py14
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-181/eric-cheung/python/ch-1.py b/challenge-181/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..91c2f53377
--- /dev/null
+++ b/challenge-181/eric-cheung/python/ch-1.py
@@ -0,0 +1,18 @@
+
+strInputSent = "All he could think about was how it would all end. There was still a bit of uncertainty in the equation, but the basics were there for anyone to see. No matter how much he tried to see the positive, it wasn't anywhere to be seen. The end was coming and it wasn't going to be pretty."
+
+arrSentence = strInputSent.split(".")
+
+strOuputSent = ""
+
+for strSentence in arrSentence:
+
+ arrEachSentence = strSentence.split()
+ arrEachSentence = sorted(arrEachSentence, key = str.casefold)
+
+ if strOuputSent:
+ strOuputSent = strOuputSent + ". "
+
+ strOuputSent = strOuputSent + " ".join(arrEachSentence)
+
+print (strOuputSent)
diff --git a/challenge-181/eric-cheung/python/ch-2.py b/challenge-181/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..c28d9c8fd7
--- /dev/null
+++ b/challenge-181/eric-cheung/python/ch-2.py
@@ -0,0 +1,14 @@
+
+import pandas as pd
+import numpy as np
+
+
+df = pd.read_csv("Temperature.txt", sep = ",", header = None, names = ["Date", "Temperature"])
+df.sort_values(by = ["Date"], inplace = True)
+df["Match"] = (df.Temperature > df.Temperature.shift())
+
+nIndxArr = np.where(df["Match"] == True)
+
+arrData = df["Date"].iloc[nIndxArr]
+
+print (np.stack(arrData).astype(str))