Since iTutor only allows you to confirm that your code works (and not to see what is particularly wrong with it), I’ve realized it may be helpful to others who get stuck to have working code to look at. It’d be too time-consuming for me to explain every scrap of code I post, so I’ll leave these snippets naked. If, however, you’re really stuck on a problem AND looking at this code doesn’t help, feel free to comment or email me and I’ll try to walk you through it. Also note that there are an infinite number of ways to solve these problems and mine is by no means necessarily the ‘best’ by any measure. Be creative and explore other ways to approach these problems too!
4.1.1
Part 1: Simple Log
(define simple-log (lambda (n) (help n 0)))
(define (help n count)
(if (= n 1) count
(help (/ n 2) (+ count 1))))
*Note: I wrote this iteratively rather than recursively (as iTutor requested) because it seems counter-productive to practice writing slow, clunky code.
Tags: No Comments
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.