aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-08-04 06:00:19 +0100
committerGitHub <noreply@github.com>2021-08-04 06:00:19 +0100
commit07a47a72dc17d1416860fb6f87369358635ceddd (patch)
treea7d3a5735949f45f2739f6f73beb338ec8cb3c39
parent54c6a275b8512ff01b05c21abcf24d5c067b3298 (diff)
parenta30cb1b9a1bde61934e25e6166e7ee605a470587 (diff)
downloadperlweeklychallenge-club-07a47a72dc17d1416860fb6f87369358635ceddd.tar.gz
perlweeklychallenge-club-07a47a72dc17d1416860fb6f87369358635ceddd.tar.bz2
perlweeklychallenge-club-07a47a72dc17d1416860fb6f87369358635ceddd.zip
Merge pull request #4654 from stuart-little/stuart-little_124_python
1st commit on 124_python
-rwxr-xr-xchallenge-124/stuart-little/python/ch-1.py23
-rwxr-xr-xchallenge-124/stuart-little/python/ch-2.py12
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-124/stuart-little/python/ch-1.py b/challenge-124/stuart-little/python/ch-1.py
new file mode 100755
index 0000000000..b8d831813b
--- /dev/null
+++ b/challenge-124/stuart-little/python/ch-1.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# run <script>
+
+print("""
+ ^^^^^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^^^^^
+ ^
+ ^
+ ^
+ ^^^^^
+ ^
+ ^
+""")
diff --git a/challenge-124/stuart-little/python/ch-2.py b/challenge-124/stuart-little/python/ch-2.py
new file mode 100755
index 0000000000..0da114bb30
--- /dev/null
+++ b/challenge-124/stuart-little/python/ch-2.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+# run <script> <space-separated numbers>
+
+from itertools import combinations
+import sys
+
+def splt(nums):
+ return(min([(cmb,tuple(set(nums).difference(cmb))) for cmb in combinations(nums,len(nums)//2)], key=lambda tup: abs(sum(tup[0]) - sum(tup[1]))))
+
+for ar in splt([int(x) for x in sys.argv[1:]]):
+ print(ar)