diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-13 06:51:38 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-13 06:51:38 +0000 |
| commit | d1cdd6bd2914289bf868f4cdd4c99979d5464a13 (patch) | |
| tree | e69d5e1f31a95c9832902756298e063e71ce84ba /challenge-203/eric-cheung/python | |
| parent | 5ccac734c46826df9dedf843701fb1514175c2a6 (diff) | |
| download | perlweeklychallenge-club-d1cdd6bd2914289bf868f4cdd4c99979d5464a13.tar.gz perlweeklychallenge-club-d1cdd6bd2914289bf868f4cdd4c99979d5464a13.tar.bz2 perlweeklychallenge-club-d1cdd6bd2914289bf868f4cdd4c99979d5464a13.zip | |
- Added solutions by Mark Anderson.
- Added solutions by W. Luis Mochan.
- Added solutions by Peter Campbell Smith.
- Added solutions by Duncan C. White.
- Added solutions by Luca Ferrari.
- Added solutions by Dave Jacoby.
- Added solutions by David Ferrone.
- Added solutions by Thomas Kohler.
- Added solutions by Mariano Spadaccini.
- Added solutions by Carlos Oliveira.
- Added solutions by Roger Bell_West.
- Added solutions by Chicagoist.
- Added solutions by Robbie Hatley.
- Added solutions by Jorg Sommrey.
- Added solutions by E. Choroba.
- Added solutions by Kjetil Skotheim.
- Added solutions by Arne Sommer.
- Added solutions by Pip Stuart.
- Added solutions by Robert Ransbottom.
- Added solutions by Athanasius.
- Added solutions by James Smith.
- Added solutions by Flavio Poletti.
- Added solutions by Cheok-Yin Fung.
- Added solutions by Solathian.
- Added solutions by Jan Krnavek.
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Reike.
- Added solutions by Robert DiCicco.
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)
|
