summaryrefslogtreecommitdiff
path: root/coding-exercises
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-05-09 22:29:14 +0200
committerMike Vink <mike1994vink@gmail.com>2023-05-09 22:29:14 +0200
commit78f438c53b0aaf147268a77dfd53f5b056939f39 (patch)
treeeca7d01730821f09ea55ad2330a5a19352cb208a /coding-exercises
parent591bda19951558d40d6ad11b49941c9ce8cd5704 (diff)
two more excercises
Diffstat (limited to 'coding-exercises')
-rw-r--r--coding-exercises/2/93.rkt28
1 files changed, 28 insertions, 0 deletions
diff --git a/coding-exercises/2/93.rkt b/coding-exercises/2/93.rkt
index 2543b23..5eb7221 100644
--- a/coding-exercises/2/93.rkt
+++ b/coding-exercises/2/93.rkt
@@ -36,3 +36,31 @@
(term 1 -1))))
(display (list "RESULT GCD --" (greatest-common-divisor test-p1 test-p2)))))
+
+;; 95
+;; I represented reals as inexact decimals so our gcd breaks down here
+;; Even more, I didn't bother with inexact gcd and the real gcd just returns the dividend
+((lambda ()
+ (define p1 (make-polynomial 'x
+ (sparse-termlist
+ (term 2 1) (term 1 -2) (term 0 1))))
+ (define p2 (make-polynomial 'x
+ (sparse-termlist
+ (term 2 11) (term 0 7))))
+ (define p3 (make-polynomial 'x
+ (sparse-termlist
+ (term 1 13) (term 0 5))))
+ (define q1 (mul p1 p2))
+ (define q2 (mul p1 p3))
+ (newline)
+ (newline)
+ (newline)
+ (newline)
+ (newline)
+ (display q1)
+ (newline)
+ (display q2)
+ (newline)
+ (display (greatest-common-divisor q1 q2))))
+
+;; 96