aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-124/stuart-little/node/ch-1.js23
-rwxr-xr-xchallenge-124/stuart-little/node/ch-2.js15
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-124/stuart-little/node/ch-1.js b/challenge-124/stuart-little/node/ch-1.js
new file mode 100755
index 0000000000..3a5c70ff8f
--- /dev/null
+++ b/challenge-124/stuart-little/node/ch-1.js
@@ -0,0 +1,23 @@
+#!/usr/bin/env node
+
+// run <script>
+
+console.log(`
+ ^^^^^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^^^^^
+ ^
+ ^
+ ^
+ ^^^^^
+ ^
+ ^
+`)
diff --git a/challenge-124/stuart-little/node/ch-2.js b/challenge-124/stuart-little/node/ch-2.js
new file mode 100755
index 0000000000..70aaa0deeb
--- /dev/null
+++ b/challenge-124/stuart-little/node/ch-2.js
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+
+// run <script> <space-separated numbers>
+
+const { minBy, sum } = require('lodash')
+const { difference } = require('set-operations')
+const ps = require('power-set-x').default
+
+function splt(nums) {
+ return minBy(ps(nums).filter(x => x.length === Math.floor(nums.length/2)).map(x => [x, Array.from(difference(nums,x))]), x => Math.abs(sum(x[0])-sum(x[1])))
+}
+
+const [l,r] = splt(process.argv.slice(2).map(x => parseInt(x)))
+console.log(l)
+console.log(r)