sgignoux / sicp-solutions.net Goto Github PK
View Code? Open in Web Editor NEWUsed to be codology.net
Home Page: https://sicp-solutions.net
Used to be codology.net
Home Page: https://sicp-solutions.net
Hi, will there be more solutions for the remaining exercises?
These are very nice and useful, and I want to thank you for these nice solutions so far @sgignoux
I think this is just a minor typo issue, but I noticed you were using (log 100) instead of (log 1000) as stated in the problem which is changing the results.
Link:
https://github.com/albondad/codology.net/blob/master/content/post/SICP-Solution-Exercise-1-36.md
Both g(n) and h(n) should be piecewise functions where
Your solution to ex 1.13 helped me a lot to understand it; thank you.
In your concluding statement
This show that
φ^n/√5
will never be further away from the value ofFib(n)
than 1
I would change this to
This shows that
φ^n/√5
will never be further away from the value ofFib(n)
than 1/2
Since the previous statement bounds the value of φ^n/√5
to Fib(n) +/- 1/2
Towards the end of the solution for 1.14 (below the text "by continuing to apply the formulas") it is stated that the summands should be:
T(n-10i,1) for T(n,3)
T(n-25i,1) for T(n,4)
T(n-50i, 1) for T(n,5)
But it seems it should be:
T(n-10i,2) for T(n,3)
T(n-25i,3) for T(n,4)
T(n-50i,4) for T(n,5)
Hi, thank you for making your solutions and work available. It is nice having your insight available as I work through the wizard book!
In your solution for 1.14 you have a slight typo in the below section
Let's break it down:
- There are 4 green nodes for `(c x 2)` corresponding to how many time you can subtract a dime from 12, plus one.
- Then for each of the green node, there is the option of using only dime, which is the case that we looked at first.
You say dime, but in the example you are showing nickels.
Interval boundaries should be checked as well:
#;1> (div-interval (make-interval 1 2) (make-interval 22 0))
Error: (/) division by zero
1.0
0
Call history:
<eval> [div-interval] (lower-bound y)
<eval> [lower-bound] (min (car i) (cdr i))
<eval> [lower-bound] (car i)
<eval> [lower-bound] (cdr i)
<eval> [div-interval] (mul-interval x (make-interval (/ 1.0 (upper-bound y)) (/ 1.0 (lower-bound y))))
<eval> [div-interval] (make-interval (/ 1.0 (upper-bound y)) (/ 1.0 (lower-bound y)))
<eval> [div-interval] (/ 1.0 (upper-bound y))
<eval> [div-interval] (upper-bound y)
<eval> [upper-bound] (max (car i) (cdr i))
<eval> [upper-bound] (car i)
<eval> [upper-bound] (cdr i)
<eval> [div-interval] (/ 1.0 (lower-bound y))
<eval> [div-interval] (lower-bound y)
<eval> [lower-bound] (min (car i) (cdr i))
<eval> [lower-bound] (car i)
<eval> [lower-bound] (cdr i) <--
Dear Sébastien,
I believe I have found a mistake in your solution of the Exercise 1.13
from SICP.
In the proof, you state that 0 < ψ < 1. Since ψ = (1 - sqrt(5)) / 2 ≃
−0.62, this is clearly not the case. You should add an absolute value to
the proof.
The solution to 1.17 is not tail-recursive since the branch for odd b does not call fast-mult
directly.
The solution to 1.16 is tail-recursive (and notes it). An analogous solution can be constructed for 1.17 by using 3 arguments instead of 2 and keeping a * b + c
invariant, starting with c = 0
and ending when b = 0
:
(define (iter-mult a b c)
(cond
((= b 0) c)
((even? b) (iter-mult (double a) (halve b) c))
(else (iter-mult a (- b 1) (+ c a)))))
(define (fast-mult a b)
(iter-mult a b 0))
The number 0.001 only has 1 significant digit (the 1), not 3 significant digits. The statement "0.001 has 3 significant decimal digits" is incorrect.
For some reason, it doesn't go into an infinite loop for me, ( I use the Pretty-big interpreter in DrRacket)
and the result is almost the same except for the natural numbers that have a natural square root, s.t (sqrt 4)
with normal if (sqrt 4) gives 2.0000xxxxxx which x's represent some garbage of numbers
but with the If procedure, it produces the natural number 2 w/o any fractions
The plugin to get Graphviz is broken after migrating to new themes.
Example:
The solution has a bug. For the reason, check here. In short, you need to use abs
on the result of gcd
.
You gave the following solution :
(define one (lambda (f) (lambda (x) (f (f x)))))
But this is infact 2 in Church numerals.
You can check the correct solution from the cummunity-scheme-wiki : http://community.schemewiki.org/?sicp-ex-2.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.