diff options
Diffstat (limited to 'challenge-348/eric-cheung/python')
| -rwxr-xr-x | challenge-348/eric-cheung/python/ch-1.py | 15 | ||||
| -rwxr-xr-x | challenge-348/eric-cheung/python/ch-2.py | 39 |
2 files changed, 54 insertions, 0 deletions
diff --git a/challenge-348/eric-cheung/python/ch-1.py b/challenge-348/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..4848b52c72 --- /dev/null +++ b/challenge-348/eric-cheung/python/ch-1.py @@ -0,0 +1,15 @@ +
+## strInput = "textbook" ## Example 1
+## strInput = "book" ## Example 2
+## strInput = "AbCdEfGh" ## Example 3
+## strInput = "rhythmmyth" ## Example 4
+strInput = "UmpireeAudio" ## Example 5
+
+arrVowel = ["a", "e", "i", "o", "u"]
+
+nLen = int(len(strInput) / 2)
+
+nVowel_01 = len([charLoop for charLoop in strInput[:nLen].lower() if charLoop in arrVowel])
+nVowel_02 = len([charLoop for charLoop in strInput[nLen:].lower() if charLoop in arrVowel])
+
+print (nVowel_01 == nVowel_02 and nVowel_01 > 0)
diff --git a/challenge-348/eric-cheung/python/ch-2.py b/challenge-348/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..5f2d6f9969 --- /dev/null +++ b/challenge-348/eric-cheung/python/ch-2.py @@ -0,0 +1,39 @@ +
+from datetime import datetime, timedelta
+
+## Example 1
+## strSource = "02:30"
+## strTarget = "02:45"
+
+## Example 2
+## strSource = "11:55"
+## strTarget = "12:15"
+
+## Example 3
+## strSource = "09:00"
+## strTarget = "13:00"
+
+## Example 4
+## strSource = "23:45"
+## strTarget = "00:30"
+
+## Example 5
+strSource = "14:20"
+strTarget = "15:25"
+
+arrMin = [60, 15, 5, 1]
+strTimeFormat = "%H:%M"
+
+nDayAdd = (1 if strSource > strTarget else 0)
+
+objSource = datetime.strptime(strSource, strTimeFormat)
+objTarget = datetime.strptime(strTarget, strTimeFormat) + timedelta(days = nDayAdd)
+
+nMinDiff = int((objTarget - objSource).total_seconds() / 60)
+nOperation = 0
+
+for nMinLoop in arrMin:
+ nOperation = nOperation + int(nMinDiff / nMinLoop)
+ nMinDiff = nMinDiff - int(nMinDiff / nMinLoop) * nMinLoop
+
+print (nOperation)
|
