From d1cdd6bd2914289bf868f4cdd4c99979d5464a13 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 13 Feb 2023 06:51:38 +0000 Subject: - 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. --- challenge-203/eric-cheung/python/ch-1.py | 27 +++++++++++++++++++++++++++ challenge-203/eric-cheung/python/ch-2.py | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 challenge-203/eric-cheung/python/ch-1.py create mode 100755 challenge-203/eric-cheung/python/ch-2.py (limited to 'challenge-203/eric-cheung/python') 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) -- cgit