aboutsummaryrefslogtreecommitdiff
path: root/challenge-268/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-05-06 11:19:31 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-05-06 11:19:31 +0100
commit479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde (patch)
treea833604c9880a15ef297b9f9378d333f7018160e /challenge-268/eric-cheung/python/ch-1.py
parent2613c50fbf02be26a82bb14a464fa61d2afc23ac (diff)
downloadperlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.tar.gz
perlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.tar.bz2
perlweeklychallenge-club-479ca4e9c71aa2ea5be2bc7b66451c21be9d8dde.zip
- Added solutions by Eric Cheung.
- Added solutions by Mark Anderson. - Added solutions by Feng Chang. - Added solutions by PokGoPun.
Diffstat (limited to 'challenge-268/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-268/eric-cheung/python/ch-1.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-268/eric-cheung/python/ch-1.py b/challenge-268/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..093fd3f45c
--- /dev/null
+++ b/challenge-268/eric-cheung/python/ch-1.py
@@ -0,0 +1,25 @@
+
+## Example 1
+## arrX = [3, 7, 5]
+## arrY = [9, 5, 7]
+
+## Example 2
+## arrX = [1, 2, 1]
+## arrY = [5, 4, 4]
+
+## Example 3
+arrX = [2]
+arrY = [5]
+
+arrX = sorted(arrX)
+arrY = sorted(arrY)
+
+nDiff = arrY[0] - arrX[0]
+
+bIsSameDiff = True
+for nIndx in range(1, len(arrX)):
+ if arrY[nIndx] - arrX[nIndx] != nDiff:
+ bIsSameDiff = False
+ break
+
+print (nDiff if bIsSameDiff else "")