diff options
Diffstat (limited to 'challenge-254/eric-cheung/python')
| -rwxr-xr-x | challenge-254/eric-cheung/python/ch-1.py | 13 | ||||
| -rwxr-xr-x | challenge-254/eric-cheung/python/ch-2.py | 24 |
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-254/eric-cheung/python/ch-1.py b/challenge-254/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..3a08de1539 --- /dev/null +++ b/challenge-254/eric-cheung/python/ch-1.py @@ -0,0 +1,13 @@ +
+import math
+
+## nInput = 27 ## Example 1
+## nInput = 0 ## Example 2
+nInput = 6 ## Example 3
+
+dCubicRoot = nInput ** (1. / 3.)
+
+if dCubicRoot - int(dCubicRoot) > 0:
+ print (False)
+else:
+ print (True)
diff --git a/challenge-254/eric-cheung/python/ch-2.py b/challenge-254/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..e1a9c3c14f --- /dev/null +++ b/challenge-254/eric-cheung/python/ch-2.py @@ -0,0 +1,24 @@ +
+## Reference
+## https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-71.php
+## https://www.geeksforgeeks.org/reverse-vowels-given-string/
+
+## strInput = "Raku" ## Example 1
+## strInput = "Perl" ## Example 2
+## strInput = "Julia" ## Example 3
+strInput = "Uiua" ## Example 4
+
+arrVowel = [charLoop for charLoop in strInput.lower() if charLoop in ["a", "e", "i", "o", "u"]]
+
+strOutput = ""
+
+for nIndx, charLoop in enumerate(strInput.lower()):
+ if charLoop in ["a", "e", "i", "o", "u"]:
+ strOutput = strOutput + arrVowel[-1]
+ del arrVowel[-1]
+ else:
+ strOutput = strOutput + charLoop
+
+strOutput = strOutput.title()
+
+print (strOutput)
|
