diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-10-20 16:59:39 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-10-20 16:59:39 +0100 |
| commit | 79fbae1caeecaa7ecf19384997d7955baa548591 (patch) | |
| tree | 85a00a8c8d938ad31c239fd853ce46872cfe87eb /challenge-344/eric-cheung/python | |
| parent | 825716d3c81ed9d4659931c741b83b03717e5d47 (diff) | |
| download | perlweeklychallenge-club-79fbae1caeecaa7ecf19384997d7955baa548591.tar.gz perlweeklychallenge-club-79fbae1caeecaa7ecf19384997d7955baa548591.tar.bz2 perlweeklychallenge-club-79fbae1caeecaa7ecf19384997d7955baa548591.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Andrew Shitov.
- Added solutions by Mark Anderson.
- Added solutions by Jaldhar H. Vyas.
- Added solutions by Benjamin Andre.
- Added solutions by Andreas Mahnke.
- Added solutions by E. Choroba.
- Added solutions by PokGoPun.
- Added solutions by Vinod Kumar K.
- Added solutions by Luca Ferrari.
- Added solutions by David Ferrone.
Diffstat (limited to 'challenge-344/eric-cheung/python')
| -rwxr-xr-x | challenge-344/eric-cheung/python/ch-1.py | 25 | ||||
| -rwxr-xr-x | challenge-344/eric-cheung/python/ch-2.py | 34 |
2 files changed, 59 insertions, 0 deletions
diff --git a/challenge-344/eric-cheung/python/ch-1.py b/challenge-344/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..23cff3d29a --- /dev/null +++ b/challenge-344/eric-cheung/python/ch-1.py @@ -0,0 +1,25 @@ +
+## Example 1
+## arrInt = [1, 2, 3, 4]
+## nX = 12
+
+## Example 2
+## arrInt = [2, 7, 4]
+## nX = 181
+
+## Example 3
+## arrInt = [9, 9, 9]
+## nX = 1
+
+## Example 4
+## arrInt = [1, 0, 0, 0, 0]
+## nX = 9999
+
+## Example 5
+arrInt = [0]
+nX = 1000
+
+nOutput = int("".join([str(nLoop) for nLoop in arrInt])) + nX
+arrOutput = [int(strLoop) for strLoop in str(nOutput)]
+
+print (arrOutput)
diff --git a/challenge-344/eric-cheung/python/ch-2.py b/challenge-344/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..6aaef3792d --- /dev/null +++ b/challenge-344/eric-cheung/python/ch-2.py @@ -0,0 +1,34 @@ +
+from itertools import permutations
+
+## Example 1
+## arrSource = [[2, 3], [1], [4]]
+## arrTarget = [1, 2, 3, 4]
+
+## Example 2
+## arrSource = [[1, 3], [2, 4]]
+## arrTarget = [1, 2, 3, 4]
+
+## Example 3
+## arrSource = [[9, 1], [5, 8], [2]]
+## arrTarget = [5, 8, 2, 9, 1]
+
+## Example 4
+## arrSource = [[1], [3]]
+## arrTarget = [1, 2, 3]
+
+## Example 5
+arrSource = [[7, 4, 6]]
+arrTarget = [7, 4, 6]
+
+strTarget = "".join(map(str, arrTarget))
+arrPerm = permutations(arrSource)
+
+bIsFound = False
+for arrLoop in arrPerm:
+ strTemp = "".join(["".join(map(str, arrSubLoop)) for arrSubLoop in arrLoop])
+ if strTarget == strTemp:
+ bIsFound = True
+ break
+
+print (bIsFound)
|
