aboutsummaryrefslogtreecommitdiff
path: root/challenge-134/abigail
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-10-13 16:00:39 +0200
committerAbigail <abigail@abigail.be>2021-10-13 17:09:20 +0200
commitdb527915f68dd2e3cb2948d56f9e458164af67de (patch)
treef0fcef5d1aa3eceadd75a56b645cbff04e0cf2e9 /challenge-134/abigail
parent81fd095a431fccee85ca6fb37785ff4567e7de52 (diff)
downloadperlweeklychallenge-club-db527915f68dd2e3cb2948d56f9e458164af67de.tar.gz
perlweeklychallenge-club-db527915f68dd2e3cb2948d56f9e458164af67de.tar.bz2
perlweeklychallenge-club-db527915f68dd2e3cb2948d56f9e458164af67de.zip
Scheme solution for week 134
Diffstat (limited to 'challenge-134/abigail')
-rw-r--r--challenge-134/abigail/README.md2
-rw-r--r--challenge-134/abigail/scheme/ch-1.scm14
-rw-r--r--challenge-134/abigail/scheme/ch-2.scm41
3 files changed, 57 insertions, 0 deletions
diff --git a/challenge-134/abigail/README.md b/challenge-134/abigail/README.md
index 72ad1c8f12..af093cceb0 100644
--- a/challenge-134/abigail/README.md
+++ b/challenge-134/abigail/README.md
@@ -16,6 +16,7 @@
* [Perl](perl/ch-1.pl)
* [Python](python/ch-1.py)
* [Ruby](ruby/ch-1.rb)
+* [Scheme](scheme/ch-1.scm)
* [Tcl](tcl/ch-1.tcl)
## Part 2
@@ -31,4 +32,5 @@
* [Perl](perl/ch-2.pl)
* [Python](python/ch-2.py)
* [Ruby](ruby/ch-2.rb)
+* [Scheme](scheme/ch-2.scm)
* [Tcl](tcl/ch-2.tcl)
diff --git a/challenge-134/abigail/scheme/ch-1.scm b/challenge-134/abigail/scheme/ch-1.scm
new file mode 100644
index 0000000000..bd23884d91
--- /dev/null
+++ b/challenge-134/abigail/scheme/ch-1.scm
@@ -0,0 +1,14 @@
+;;;
+;;; See ../README.md
+;;;
+
+;;;
+;;; Run as: guile --no-auto-compile ch-1.scm
+;;;
+
+(use-modules (ice-9 format))
+
+(define t #@1(789 798 879 897 978))
+(do ((i 1 (1+ i)))
+ ((> i (array-length t)))
+ (format #t "1023456~d\n" (array-ref t i)))
diff --git a/challenge-134/abigail/scheme/ch-2.scm b/challenge-134/abigail/scheme/ch-2.scm
new file mode 100644
index 0000000000..25874c204a
--- /dev/null
+++ b/challenge-134/abigail/scheme/ch-2.scm
@@ -0,0 +1,41 @@
+;;;
+;;; See ../README.md
+;;;
+
+;;;
+;;; Run as: guile --no-auto-compile ch-2.scm < input-file
+;;;
+
+
+(define (main)
+ (define m (read))
+ (define n (read))
+ (define count 0)
+ (define seen #())
+ (if (not (eof-object? m))
+ (begin
+ (set! seen (make-array 0 (+ 1 (* m n))))
+ (do ((i 1 (1+ i)))
+ ((> i n))
+ (begin
+ (do ((j 1 (1+ j)))
+ ((> j m))
+ (begin
+ (if (= (array-ref seen (* i j)) 0)
+ (begin
+ (array-set! seen 1 (* i j))
+ (set! count (1+ count))
+ )
+ )
+ )
+ )
+ )
+ )
+ (display count)
+ (newline)
+ (main)
+ )
+ )
+)
+
+(main)