From e2bcd5b91f30ead0274fca78de01038b4432995b Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 12 Jun 2023 05:17:44 +0100 Subject: - Added solutions by Roger Bell_West. - Added solutions by Robert DiCicco. - Added solutions by Ulrich Rieke. - Added solutions by Laurent Rosenfeld. - Added solutions by Niels van Dijke. - Added solutions by Simon Proctor. - Added solutions by Mark Anderson. - Added solutions by Peter Meszaros. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Thomas Kohler. - Added solutions by Stephen G. Lynn. - Added solutions by Peter Campbell Smith. - Added solutions by E. Choroba. - Added solutions by Robbie Hatley. - Added solutions by Jorg Sommrey. - Added solutions by Cheok-Yin Fung. - Added solutions by Robert Ransbottom. - Added solutions by Flavio Poletti. - Added solutions by Jaldhar H. Vyas. - Added solutions by Avery Adams. - Added solutions by Bob Lied. - Added solutions by Athanasius. - Added solutions by Simon Green. - Added solutions by Jan Krnavek. - Added solutions by Lubos Kolouch. - Added solutions by BarrOff. - Added solutions by Solathian. - Added solutions by Matthias Muth. --- challenge-220/eric-cheung/python/ch-1.py | 17 +++++++++++++++++ challenge-220/eric-cheung/python/ch-2.py | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 challenge-220/eric-cheung/python/ch-1.py create mode 100755 challenge-220/eric-cheung/python/ch-2.py (limited to 'challenge-220/eric-cheung/python') diff --git a/challenge-220/eric-cheung/python/ch-1.py b/challenge-220/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..5ee515aea5 --- /dev/null +++ b/challenge-220/eric-cheung/python/ch-1.py @@ -0,0 +1,17 @@ + +## arrWordList = ["Perl", "Rust", "Raku"] ## Example 1 +arrWordList = ["love", "live", "leave"] ## Example 2 + +arrOutputList = [] + +for charLoop in arrWordList[0]: + bExist = True + for wordLoop in arrWordList[1:]: + if not charLoop in wordLoop.lower(): + bExist = False + break + + if bExist: + arrOutputList.append(charLoop) + +print (arrOutputList) diff --git a/challenge-220/eric-cheung/python/ch-2.py b/challenge-220/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..9370992564 --- /dev/null +++ b/challenge-220/eric-cheung/python/ch-2.py @@ -0,0 +1,26 @@ + +from itertools import permutations +from math import sqrt + +def IsPerfectSqr (nInput): + dSqRoot = int(sqrt(nInput)) + return (dSqRoot * dSqRoot == nInput) + +arrIntList = [1, 17, 8] ## Example 1 +## arrIntList = [2, 2, 2] ## Example 2 + +arrOutputList = [] + +arrPerm = set(permutations(arrIntList)) + +for permLoop in list(arrPerm): + bIsSqrFul = True + for nIndx in range(0, len(permLoop) - 1): + if not IsPerfectSqr(permLoop[nIndx] + permLoop[nIndx + 1]): + bIsSqrFul = False + break + + if bIsSqrFul and not permLoop in arrOutputList: + arrOutputList.append(permLoop) + +print (arrOutputList) -- cgit