aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-11-23 16:00:43 +0100
committerAbigail <abigail@abigail.be>2021-11-25 17:19:51 +0100
commitfb39699b31d65405e7d104ee2b1c1c4edcdf51a8 (patch)
treee33b7f66d49b274f4a8a322f2651d87d9d400b78
parentfd4849655113ac9706753441de784780cc72c389 (diff)
downloadperlweeklychallenge-club-fb39699b31d65405e7d104ee2b1c1c4edcdf51a8.tar.gz
perlweeklychallenge-club-fb39699b31d65405e7d104ee2b1c1c4edcdf51a8.tar.bz2
perlweeklychallenge-club-fb39699b31d65405e7d104ee2b1c1c4edcdf51a8.zip
Solutions for week 140, part 1.
-rw-r--r--challenge-140/abigail/README.md1
-rw-r--r--challenge-140/abigail/awk/ch-1.awk38
-rw-r--r--challenge-140/abigail/awk/ch-2.awk29
-rw-r--r--challenge-140/abigail/bash/ch-1.sh42
-rw-r--r--challenge-140/abigail/bash/ch-2.sh32
-rw-r--r--challenge-140/abigail/bc/ch-1.bc18
-rw-r--r--challenge-140/abigail/bc/ch-2.bc29
-rw-r--r--challenge-140/abigail/c/ch-1.c62
-rw-r--r--challenge-140/abigail/c/ch-2.c39
-rw-r--r--challenge-140/abigail/go/ch-1.go32
-rw-r--r--challenge-140/abigail/go/ch-2.go37
-rw-r--r--challenge-140/abigail/java/ch-1.java22
-rw-r--r--challenge-140/abigail/java/ch-2.java33
-rw-r--r--challenge-140/abigail/lua/ch-1.lua28
-rw-r--r--challenge-140/abigail/lua/ch-2.lua30
-rw-r--r--challenge-140/abigail/node/ch-1.js17
-rw-r--r--challenge-140/abigail/node/ch-2.js28
-rw-r--r--challenge-140/abigail/pascal/ch-1.p40
-rw-r--r--challenge-140/abigail/pascal/ch-2.p36
-rw-r--r--challenge-140/abigail/python/ch-1.py15
-rw-r--r--challenge-140/abigail/python/ch-2.py25
-rw-r--r--challenge-140/abigail/r/ch-1.r22
-rw-r--r--challenge-140/abigail/r/ch-2.r33
-rw-r--r--challenge-140/abigail/ruby/ch-1.rb15
-rw-r--r--challenge-140/abigail/ruby/ch-2.rb27
-rw-r--r--challenge-140/abigail/scheme/ch-1.scm41
-rw-r--r--challenge-140/abigail/scheme/ch-2.scm62
-rw-r--r--challenge-140/abigail/t/ctest.ini11
-rw-r--r--challenge-140/abigail/t/input-1-13
-rw-r--r--challenge-140/abigail/t/input-2-12
-rw-r--r--challenge-140/abigail/t/output-1-1.exp3
-rw-r--r--challenge-140/abigail/t/output-2-1.exp2
-rw-r--r--challenge-140/abigail/tcl/ch-1.tcl29
-rw-r--r--challenge-140/abigail/tcl/ch-2.tcl24
34 files changed, 906 insertions, 1 deletions
diff --git a/challenge-140/abigail/README.md b/challenge-140/abigail/README.md
index bb2b1dda43..0707d1fbd5 100644
--- a/challenge-140/abigail/README.md
+++ b/challenge-140/abigail/README.md
@@ -6,7 +6,6 @@
* [Bash](bash/ch-1.sh)
* [Bc](bc/ch-1.bc)
* [C](c/ch-1.c)
-* [Erlang](c/ch-1.erl)
* [Go](go/ch-1.go)
* [Java](java/ch-1.java)
* [Lua](lua/ch-1.lua)
diff --git a/challenge-140/abigail/awk/ch-1.awk b/challenge-140/abigail/awk/ch-1.awk
new file mode 100644
index 0000000000..3210e7b108
--- /dev/null
+++ b/challenge-140/abigail/awk/ch-1.awk
@@ -0,0 +1,38 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-1.awk < input-file
+#
+
+#
+# Take a binary representation, return its decimal equivalent
+#
+function bin2dec (bin, dec, digits, n) {
+ dec = 0
+ n = split (bin, digits, "")
+ for (i = 1; i <= n; i ++) {
+ dec = 2 * dec + digits [i]
+ }
+ return (dec)
+}
+
+
+#
+# Get a binary representation
+#
+function dec2bin (dec, bin) {
+ while (dec) {
+ bin = dec % 2 bin
+ dec = int (dec / 2)
+ }
+ return (bin)
+}
+
+
+{
+ print dec2bin(bin2dec($1) + bin2dec($2))
+}
diff --git a/challenge-140/abigail/awk/ch-2.awk b/challenge-140/abigail/awk/ch-2.awk
new file mode 100644
index 0000000000..32372950cc
--- /dev/null
+++ b/challenge-140/abigail/awk/ch-2.awk
@@ -0,0 +1,29 @@
+#!/usr/bin/awk
+
+#
+# See ../README.md
+#
+
+#
+# Run as: awk -f ch-2.awk < input-file
+#
+
+{
+ i = $1
+ j = $2
+ k = $3
+
+ n = 0
+ while (k > 0) {
+ n ++
+ s = int (sqrt (n))
+ for (d = 1; d <= s && k > 0; d ++) {
+ if (!(n % d)) {
+ k -= (d <= i && n / d <= j) + \
+ (d <= j && n / d <= i) - (n == d * d)
+ }
+ }
+ }
+ print (n)
+}
+
diff --git a/challenge-140/abigail/bash/ch-1.sh b/challenge-140/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..24b57c5079
--- /dev/null
+++ b/challenge-140/abigail/bash/ch-1.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-1.sh < input-file
+#
+
+#
+# Take a binary representation, return its decimal equivalent
+#
+function bin2dec () {
+ local bin=$1
+ local i
+ ((dec = 0))
+ for ((i = 0; i < ${#bin}; i ++)) {
+ ((dec = 2 * dec + ${bin:$i:1}))
+ }
+}
+
+#
+# Given a decimal number, return its binary representation
+#
+function dec2bin () {
+ local dec=$1
+ bin=""
+ while ((dec > 0))
+ do bin=$((dec % 2))$bin
+ ((dec /= 2))
+ done
+}
+
+set -f
+
+while read a b
+do bin2dec $a; a=$dec
+ bin2dec $b; b=$dec
+ dec2bin $((a + b))
+ echo $bin
+done
diff --git a/challenge-140/abigail/bash/ch-2.sh b/challenge-140/abigail/bash/ch-2.sh
new file mode 100644
index 0000000000..16757fccb3
--- /dev/null
+++ b/challenge-140/abigail/bash/ch-2.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-2.sh < input-file
+#
+
+set -f
+
+while read i j k
+do ((n = 0))
+ while ((k > 0))
+ do ((n ++))
+ for ((d = 1; d * d <= n && k > 0; d ++))
+ do if ((n % d == 0))
+ then if ((d <= i && n / d <= j))
+ then ((k --))
+ fi
+ if ((d <= j && n / d <= i))
+ then ((k --))
+ fi
+ if ((n == d * d))
+ then ((k ++))
+ fi
+ fi
+ done
+ done
+ echo $n
+done
diff --git a/challenge-140/abigail/bc/ch-1.bc b/challenge-140/abigail/bc/ch-1.bc
new file mode 100644
index 0000000000..9e1fe422ad
--- /dev/null
+++ b/challenge-140/abigail/bc/ch-1.bc
@@ -0,0 +1,18 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: bc ch-1.bc < input-file
+#
+
+obase=2
+ibase=2
+
+while (1) {
+ a = read(); if (a == 0) {break}
+ b = read(); if (b == 0) {break}
+ a + b
+}
+
+quit
diff --git a/challenge-140/abigail/bc/ch-2.bc b/challenge-140/abigail/bc/ch-2.bc
new file mode 100644
index 0000000000..bb4f56c509
--- /dev/null
+++ b/challenge-140/abigail/bc/ch-2.bc
@@ -0,0 +1,29 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: bc ch-2.bc < input-file
+#
+
+while (1) {
+ i = read (); if (i == 0) {break}
+ j = read (); if (j == 0) {break}
+ k = read (); if (k == 0) {break}
+
+ n = 0
+ while (k > 0) {
+ n = n + 1
+ for (d = 1; d * d <= n && k > 0; d ++) {
+ if (n % d == 0) {
+ if (d <= i && n / d <= j) {k = k - 1}
+ if (d <= j && n / d <= i) {k = k - 1}
+ if (n == d * d) {k = k + 1}
+ }
+ }
+ }
+
+ n
+}
+
+quit
diff --git a/challenge-140/abigail/c/ch-1.c b/challenge-140/abigail/c/ch-1.c
new file mode 100644
index 0000000000..6c9024bda9
--- /dev/null
+++ b/challenge-140/abigail/c/ch-1.c
@@ -0,0 +1,62 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o < input-file
+ */
+
+/*
+ * Given a decimal number, return its binary representation
+ */
+char * dec2bin (long dec) {
+ char * bin;
+ if ((bin = (char *) malloc (32 * sizeof (char))) == NULL) {
+ perror ("Malloc failed");
+ exit (1);
+ }
+ if (dec == 0) { /* Special case dec == 0 */
+ bin [0] = '0';
+ bin [1] = '\0';
+ return (bin);
+ }
+ size_t i = 0;
+ while (dec) {
+ bin [i ++] = '0' + dec % 2;
+ dec /= 2;
+ }
+ /*
+ * Reverse the string
+ */
+ for (size_t j = 0; j < i / 2; j ++) {
+ char t = bin [j];
+ bin [j] = bin [i - j - 1];
+ bin [i - j - 1] = t;
+ }
+
+ bin [i] = '\0';
+ return (bin);
+}
+
+
+int main (void) {
+ char * line = NULL;
+ size_t len = 0;
+ size_t str_len;
+
+ while ((str_len = getline (&line, &len, stdin)) != -1) {
+ char * end_ptr;
+ long a = strtol (line, &end_ptr, 2);
+ long b = strtol (end_ptr, NULL, 2);
+ char * bin = dec2bin (a + b);
+ printf ("%s\n", bin);
+ free (bin);
+ }
+ free (line);
+
+ return (0);
+}
diff --git a/challenge-140/abigail/c/ch-2.c b/challenge-140/abigail/c/ch-2.c
new file mode 100644
index 0000000000..b57fb1d955
--- /dev/null
+++ b/challenge-140/abigail/c/ch-2.c
@@ -0,0 +1,39 @@
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+# include <math.h>
+
+/*
+ * See ../README.md
+ */
+
+/*
+ * Run as: cc -o ch-2.o ch-2.c; ./ch-2.o < input-file
+ */
+
+int main (void) {
+ long i, j;
+ long long k;
+
+ while (scanf ("%ld%ld%lld", &i, &j, &k) == 3) {
+ long long n = 0;
+ while (k > 0) {
+ long s = lrintf (sqrt (++ n));
+ for (long d = 1; d <= s && k > 0; d ++) {
+ /*
+ * Subtract the number of divisors d, where d <= i,
+ * and n / d <= j, or d <= j and n / d <= i.
+ * A number d is a divisor if n % d == 0.
+ * We should count a divisor only once if n == d * d.
+ */
+ if (!(n % d)) {
+ k -= (d <= i && n / d <= j) +
+ (d <= j && n / d <= i) - (n == d * d);
+ }
+ }
+ }
+ printf ("%lld\n", n);
+ }
+
+ return (0);
+}
diff --git a/challenge-140/abigail/go/ch-1.go b/challenge-140/abigail/go/ch-1.go
new file mode 100644
index 0000000000..c355358d16
--- /dev/null
+++ b/challenge-140/abigail/go/ch-1.go
@@ -0,0 +1,32 @@
+package main
+
+//
+// See ../README.md
+//
+
+//
+// Run as: go run ch-1.go
+//
+
+import (
+ "fmt"
+ "bufio"
+ "os"
+ "strconv"
+ "strings"
+)
+
+func main () {
+ var reader = bufio . NewReader (os. Stdin)
+ for {
+ var text, err = reader . ReadString ('\n')
+ if (err != nil) {
+ break
+ }
+ bins := strings . Split (strings . Trim (text, "\n"), " ")
+ a, _ := strconv . ParseInt (bins [0], 2, 0)
+ b, _ := strconv . ParseInt (bins [1], 2, 0)
+
+ fmt . Println (strconv . FormatInt (a + b, 2))
+ }
+}
diff --git a/challenge-140/abigail/go/ch-2.go b/challenge-140/abigail/go/ch-2.go
new file mode 100644
index 0000000000..0f35815237
--- /dev/null
+++ b/challenge-140/abigail/go/ch-2.go
@@ -0,0 +1,37 @@
+package main
+
+//
+// See ../README.md
+//
+
+//
+// Run as: go run ch-2.go < input-file
+//
+
+import (
+ "fmt"
+ "math"
+)
+
+func main () {
+ for {
+ var i, j, k int64
+ c, err := fmt . Scanf ("%d %d %d", &i, &j, &k)
+ if (c != 3 || err != nil) {
+ break;
+ }
+ n := int64 (0)
+ for ;k > 0; {
+ n ++
+ s := int64 (math . Sqrt (float64 (n)))
+ for d := int64 (1); d <= s && k > 0; d ++ {
+ if (n % d == 0) {
+ if (d <= i && n / d <= j) {k --}
+ if (d <= j && n / d <= i) {k --}
+ if (n == d * d) {k ++}
+ }
+ }
+ }
+ fmt . Println (n)
+ }
+}
diff --git a/challenge-140/abigail/java/ch-1.java b/challenge-140/abigail/java/ch-1.java
new file mode 100644
index 0000000000..7d93af1d7d
--- /dev/null
+++ b/challenge-140/abigail/java/ch-1.java
@@ -0,0 +1,22 @@
+//
+// See ../README.md
+//
+
+//
+// Run as: ln ch-1.java ch1.java; javac ch1.java; java ch1 < input-file
+//
+
+import java.util.*;
+
+public class ch1 {
+ public static void main (String [] args) {
+ Scanner scanner = new Scanner (System . in);
+ while (scanner . hasNextLine ()) {
+ String line = scanner . nextLine ();
+ String [] parts = line . trim () . split (" ");
+ int a = Integer . parseInt (parts [0], 2);
+ int b = Integer . parseInt (parts [1], 2);
+ System . out . println (Integer . toBinaryString (a + b));
+ }
+ }
+}
diff --git a/challenge-140/abigail/java/ch-2.java b/challenge-140/abigail/java/ch-2.java
new file mode 100644
index 0000000000..90c4bd998f
--- /dev/null
+++ b/challenge-140/abigail/java/ch-2.java
@@ -0,0 +1,33 @@
+//
+// See ../README.md
+//
+
+//
+// Run as: ln ch-2.java ch2.java; javac ch2.java; java ch2 < input-file
+//
+
+import java.util.*;
+
+public class ch2 {
+ public static void main (String [] args) {
+ Scanner scanner = new Scanner (System . in);
+ while (scanner . hasNextLong ()) {
+ long i = scanner . nextLong ();
+ long j = scanner . nextLong ();
+ long k = scanner . nextLong ();
+ long n = 0;
+ while (k > 0) {
+ n ++;
+ long s = (long) Math . sqrt (n);
+ for (long d = 1; d <= s && k > 0; d ++) {
+ if (n % d == 0) {
+ if (d <= i && n / d <= j) {k --;}
+ if (d <= j && n / d <= i) {k --;}
+ if (n == d * d) {k ++;}
+ }
+ }
+ }
+ System . out . println (n);
+ }
+ }
+}
diff --git a/challenge-140/abigail/lua/ch-1.lua b/challenge-140/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..b0ad7ae3fd
--- /dev/null
+++ b/challenge-140/abigail/lua/ch-1.lua
@@ -0,0 +1,28 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+function dec2bin (dec)
+ local bin = {}
+ local out = ""
+ while dec > 0 do
+ bin [#bin + 1] = dec % 2
+ dec = math . floor (dec / 2)
+ end
+ for i = #bin, 1, -1 do
+ out = out .. bin [i]
+ end
+ return out
+end
+
+
+for line in io . lines () do
+ _, _, a, b = line : find ("([01]+)%s+([01]+)")
+ print (dec2bin (tonumber (a, 2) + tonumber (b, 2)))
+end
diff --git a/challenge-140/abigail/lua/ch-2.lua b/challenge-140/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..601fc35041
--- /dev/null
+++ b/challenge-140/abigail/lua/ch-2.lua
@@ -0,0 +1,30 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+for line in io . lines () do
+ local _, _, i, j, k = line : find ("([0-9]+)%s+([0-9]+)%s+([0-9]+)")
+ i = tonumber (i)
+ j = tonumber (j)
+ k = tonumber (k)
+
+ local n = 0
+ while k > 0 do
+ n = n + 1
+ local s = math . floor (math . sqrt (n))
+ for d = 1, s do
+ if n % d == 0 then
+ if d <= i and n / d <= j then k = k - 1 end
+ if d <= j and n / d <= i then k = k - 1 end
+ if n == d * d then k = k + 1 end
+ end
+ end
+ end
+ print (n)
+end
diff --git a/challenge-140/abigail/node/ch-1.js b/challenge-140/abigail/node/ch-1.js
new file mode 100644
index 0000000000..18dc51e939
--- /dev/null
+++ b/challenge-140/abigail/node/ch-1.js
@@ -0,0 +1,17 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-1.js < input-file
+//
+
+ require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', line => {
+ let [a, b] = line . trim () . split (" ");
+ console . log ((parseInt (a, 2) + parseInt (b, 2)) . toString (2))
+})
+
diff --git a/challenge-140/abigail/node/ch-2.js b/challenge-140/abigail/node/ch-2.js
new file mode 100644
index 0000000000..711c05f7de
--- /dev/null
+++ b/challenge-140/abigail/node/ch-2.js
@@ -0,0 +1,28 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-2.js < input-file
+//
+
+ require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', line => {
+ let [i, j, k] = line . split (" ") . map (_ => +_)
+ let n = 0
+ while (k > 0) {
+ n ++
+ let s = Math . floor (Math . sqrt (n))
+ for (let d = 1; d <= s && k > 0; d ++) {
+ if (n % d == 0) {
+ if (d <= i && n / d <= j) {k --}
+ if (d <= j && n / d <= i) {k --}
+ if (n == d * d) {k ++}
+ }
+ }
+ }
+ console . log (n)
+})
diff --git a/challenge-140/abigail/pascal/ch-1.p b/challenge-140/abigail/pascal/ch-1.p
new file mode 100644
index 0000000000..57e691e9c0
--- /dev/null
+++ b/challenge-140/abigail/pascal/ch-1.p
@@ -0,0 +1,40 @@
+Program ch1;
+
+uses Strutils;
+
+(* *)
+(* See ../README.md *)
+(* *)
+
+(* *)
+(* Run as: fpc -och-1.out ch-1.p; ./ch-1.out < input-file *)
+(* *)
+
+function bin2dec (bin: string): longint;
+ var
+ c: char;
+ dec: integer = 0;
+
+ begin
+ for c in bin do begin
+ dec := dec * 2;
+ if c = '1' then begin
+ dec := dec + 1;
+ end;
+ end;
+ bin2dec := dec;
+ end;
+
+var
+ n1, n2: longint;
+ a, b: string;
+
+begin
+ while not eof do begin
+ readln (n1, n2);
+ a := Dec2Numb (n1, 1, 10);
+ b := Dec2Numb (n2, 1, 10);
+
+ writeln (Dec2Numb (bin2dec (a) + bin2dec (b), 1, 2));
+ end
+end.
diff --git a/challenge-140/abigail/pascal/ch-2.p b/challenge-140/abigail/pascal/ch-2.p
new file mode 100644
index 0000000000..9eb1661bfc
--- /dev/null
+++ b/challenge-140/abigail/pascal/ch-2.p
@@ -0,0 +1,36 @@
+Program ch2;
+
+(* *)
+(* See ../README.md *)
+(* *)
+
+(* *)
+(* Run as: fpc -och-2.out ch-2.p; ./ch-2.out < input-file *)
+(* *)
+
+uses
+ math;
+
+var
+ i, j, k, n, s, d: longint;
+
+begin
+ while not eof do begin
+ readln (i, j, k);
+
+ n := 0;
+
+ while k > 0 do begin
+ inc (n);
+ s := round (sqrt (n));
+ for d := 1 to s do begin
+ if n mod d = 0 then begin
+ if (d <= i) and (n / d <= j) then begin dec (k); end;
+ if (d <= j) and (n / d <= i) then begin dec (k); end;
+ if (n = d * d) then begin inc (k); end;
+ end
+ end
+ end;
+ writeln (n);
+ end
+end.
diff --git a/challenge-140/abigail/python/ch-1.py b/challenge-140/abigail/python/ch-1.py
new file mode 100644
index 0000000000..7002b13c03
--- /dev/null
+++ b/challenge-140/abigail/python/ch-1.py
@@ -0,0 +1,15 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ a, b = line . strip () . split (" ")
+ print (bin (int (a, 2) + int (b, 2)) [2:])
diff --git a/challenge-140/abigail/python/ch-2.py b/challenge-140/abigail/python/ch-2.py
new file mode 100644
index 0000000000..a7bdccbb49
--- /dev/null
+++ b/challenge-140/abigail/python/ch-2.py
@@ -0,0 +1,25 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+import math
+
+for line in fileinput . input ():
+ i, j, k = map (lambda x: int (x), line . strip () . split (" "))
+ n = 0
+ while k > 0:
+ n = n + 1
+ s = math . floor (math . sqrt (n))
+ for d in range (1, s + 1):
+ if n % d == 0:
+ if d <= i and n / d <= j: k = k - 1
+ if d <= j and n / d <= i: k = k - 1
+ if n == d * d: k = k + 1
+ print (n)
diff --git a/challenge-140/abigail/r/ch-1.r b/challenge-140/abigail/r/ch-1.r
new file mode 100644
index 0000000000..10fd49abb3
--- /dev/null
+++ b/challenge-140/abigail/r/ch-1.r
@@ -0,0 +1,22 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: Rscript ch-1.r < input-file
+#
+
+stdin <- file ('stdin', 'r')
+repeat {
+ line <- readLines (stdin, n = 1)
+ if (length (line) == 0) {
+ break
+ }
+
+ parts <- strsplit (line, " ")
+ a <- strtoi (parts [[1]] [[1]], 2)
+ b <- strtoi (parts [[1]] [[2]], 2)
+
+ cat (as.integer (paste (as.integer (rev (intToBits (a + b))),
+ collapse = "")), "\n")
+}
diff --git a/challenge-140/abigail/r/ch-2.r b/challenge-140/abigail/r/ch-2.r
new file mode 100644
index 0000000000..a83d05ccce
--- /dev/null
+++ b/challenge-140/abigail/r/ch-2.r
@@ -0,0 +1,33 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: Rscript ch-2.r < input-file
+#
+
+stdin <- file ('stdin', 'r')
+repeat {
+ line <- readLines (stdin, n = 1)
+ if (length (line) == 0) {
+ break
+ }
+ parts <- strsplit (line, " ")
+ list <- as.numeric (parts [[1]])
+ i <- list [[1]]
+ j <- list [[2]]
+ k <- list [[3]]
+ n <- 0
+ while (k > 0) {
+ n <- n + 1
+ s <- floor (sqrt (n))
+ for (d in 1 : s) {
+ if (n %% d == 0) {
+ if (d <= i && n / d <= j) {k = k - 1}
+ if (d <= j && n / d <= i) {k = k - 1}
+ if (n == d * d) {k = k + 1}
+ }
+ }
+ }
+ cat (sprintf ("%d\n", n))
+}
diff --git a/challenge-140/abigail/ruby/ch-1.rb b/challenge-140/abigail/ruby/ch-1.rb
new file mode 100644
index 0000000000..bc95be2323
--- /dev/null
+++ b/challenge-140/abigail/ruby/ch-1.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-1.rb < input-file
+#
+
+ARGF . each_line do
+ | line |
+ a, b = line . strip() . split (" ")
+ puts (a . to_i(2) + b . to_i(2)) . to_s(2)
+end
diff --git a/challenge-140/abigail/ruby/ch-2.rb b/challenge-140/abigail/ruby/ch-2.rb
new file mode 100644
index 0000000000..fe2f27a992
--- /dev/null
+++ b/challenge-140/abigail/ruby/ch-2.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-2.rb < input-file
+#
+
+ARGF . each_line do
+ | line |
+ i, j, k = line . strip() . split . map {|x| x . to_i}
+ n = 0
+ while k > 0 do
+ n = n + 1
+ s = Math . sqrt(n) . floor()
+ for d in 1 .. s do
+ if n % d == 0 then
+ if d <= i && n / d <= j then k = k - 1 end
+ if d <= j && n / d <= i then k = k - 1 end
+ if n == d * d then k = k + 1 end
+ end
+ end
+ end
+ puts (n)
+end
diff --git a/challenge-140/abigail/scheme/ch-1.scm b/challenge-140/abigail/scheme/ch-1.scm
new file mode 100644
index 0000000000..45c7e0fc71
--- /dev/null
+++ b/challenge-140/abigail/scheme/ch-1.scm
@@ -0,0 +1,41 @@
+;;;
+;;; See ../README.md
+;;;
+
+;;;
+;;; Run as: guile --no-auto-compile ch-1.scm
+;;;
+
+(use-modules (ice-9 rdelim))
+(use-modules (srfi srfi-1))
+
+(define (bin2dec bin)
+ (define len (string-length bin))
+ (cond ((= len 0) 0)
+ (else (+ (string->number (string-take-right bin 1))
+ (* 2 (bin2dec (string-drop-right bin 1)))))))
+
+(define (_dec2bin dec)
+ (cond ((= dec 0) "")
+ (else (string-concatenate
+ (list (_dec2bin (floor-quotient dec 2))
+ (number->string (modulo dec 2)))))))
+