aboutsummaryrefslogtreecommitdiff
path: root/challenge-203/eric-cheung/python
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-02-13 17:22:18 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-02-13 17:22:18 +0800
commit245a9bb01d688eac1ecefefb51300ffd9642df1a (patch)
tree4c51c5419246b6ca893267e879e942953cea057a /challenge-203/eric-cheung/python
parent1d7da338f23a3842739e903bfd4e06a04f341c11 (diff)
parentbb462577d3227fa25ed53ee261528d6543a8aad0 (diff)
downloadperlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.tar.gz
perlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.tar.bz2
perlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-203/eric-cheung/python')
-rwxr-xr-xchallenge-203/eric-cheung/python/ch-1.py27
-rwxr-xr-xchallenge-203/eric-cheung/python/ch-2.py19
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)