diff options
Diffstat (limited to 'challenge-203/eric-cheung/python')
| -rwxr-xr-x | challenge-203/eric-cheung/python/ch-1.py | 27 | ||||
| -rwxr-xr-x | challenge-203/eric-cheung/python/ch-2.py | 19 |
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-203/eric-cheung/python/ch-1.py b/challenge-203/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..87d2020cff --- /dev/null +++ b/challenge-203/eric-cheung/python/ch-1.py @@ -0,0 +1,27 @@ +
+from itertools import combinations
+
+## arrInputList = [1, 2, 3, 6] ## Example 1
+## arrInputList = [1, 1, 1, 3, 5] ## Example 2
+arrInputList = [3, 3, 6, 4, 5] ## Example 2
+
+
+def IsSpecialQuadruplets(arrInput):
+
+ n_a = arrInput[0]
+ n_b = arrInput[1]
+ n_c = arrInput[2]
+ n_d = arrInput[3]
+
+ return (arrInputList[n_a] + arrInputList[n_b] + arrInputList[n_c] == arrInputList[n_d])
+
+
+arrIndxList = list(range(0, len(arrInputList)))
+arrCombList = combinations(arrIndxList, 4)
+arrOutputList = []
+
+for loopComb in list(arrCombList):
+ if IsSpecialQuadruplets(loopComb):
+ arrOutputList.append(loopComb)
+
+print (len(arrOutputList))
diff --git a/challenge-203/eric-cheung/python/ch-2.py b/challenge-203/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..fedcb744a3 --- /dev/null +++ b/challenge-203/eric-cheung/python/ch-2.py @@ -0,0 +1,19 @@ +
+## Remarks
+## https://www.geeksforgeeks.org/python-copy-directory-structure-without-files/
+
+import shutil
+import os
+
+
+## Define the Function to Ignore the Files If Present in Any Folder
+def GetIgnoreFiles(strDir, strFiles):
+ return [strFileLoop for strFileLoop in strFiles if os.path.isfile(os.path.join(strDir, strFileLoop))]
+
+
+strSourceFolderPath = "/a/b/c"
+strTargetFolderPath = "/x/y"
+
+
+## Calli the shutil.copytree() method and Pass the strSourceFolderPath, strTargetFolderPath and Ignore Parameter
+shutil.copytree(strSourceFolderPath, strTargetFolderPath, ignore = GetIgnoreFiles)
|
