From 79fbae1caeecaa7ecf19384997d7955baa548591 Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 20 Oct 2025 16:59:39 +0100 Subject: - 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. --- challenge-344/eric-cheung/python/ch-1.py | 25 +++++++++++++++++++++++ challenge-344/eric-cheung/python/ch-2.py | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 challenge-344/eric-cheung/python/ch-1.py create mode 100755 challenge-344/eric-cheung/python/ch-2.py (limited to 'challenge-344/eric-cheung/python') 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) -- cgit