Solution to SICP Exercise 1.29

Solution to Exercise 1.29:

```(define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b))))```

``` (define (inc n) (+ n 1)) ```

```(define (simpsons-integral f a b n) (define (do-it h) (define (y k) (f (+ a (* k h)))) (define (simpson-term k) (* (y k) (cond ((or (= k 0) (= k n)) 1) ((odd? k) 4) (else 2)))) (* (/ h 3) (sum simpson-term 0 inc n))) (do-it (/ (- b a) n))) ```

Solution to SICP Exercise 1.28

Solution to Exercise 1.28:

```(define (square x) (* x x))```

``` (define (expmod-with-trivial-sqrt-check base exp m) (cond ((= exp 0) 1) ((even? exp) (let* ((intermediate (expmod-with-trivial-sqrt-check base (/ exp 2) m)) (squared-mod (remainder (square intermediate) m))) (if (and (not (or (= intermediate 1) (= intermediate (- m 1)))) (= squared-mod 1)) 0 squared-mod))) (else (remainder (* base (expmod-with-trivial-sqrt-check base (- exp 1) m)) m)))) ```

```(define (miller-rabin-test n) (define (try-it a ) (= (expmod-with-trivial-sqrt-check a (- n 1) n) 1)) (try-it (+ 1 (random (- n 1)))))```

Request for comments: Online charity raffle

It’s been a while since I announced on this blog that I’m planning to walk in the Weekend to End Breast Cancer. I still haven’t raised many funds. I haven’t done very much either, which entirely explains it. Anyways, it’s about time I give this event some attention and start raising some money. So here goes nothing…

I’ve been giving some thought to one particular way I might solicit some donations and I’d would like to get your thoughts on it.

I’ve been toying with the idea of running an online raffle to raise money for the event. It is an idea inspired by John Chow’s link-building contests, but in my case, I’m more interested in raising money for breast cancer research than I am in promoting this blog.

I’m thinking of making the prize an iPod nano — a pink one, in keeping with the pink ribbons associated with the cause. If I had to guess the first rule about running a raffle, it would be that the prize has to be worth winning. Those iPods seem to be universally adored, so I think I’d be safe with one of those.

Here’s how I’m thinking it would work.

The raffle would be open to anybody and there would be several ways to enter:

1. Make a donation – I’m thinking there would have to be some minimal donation for entry in the contest. An amount of \$10 comes to mind.
2. Spread the word by blog – A blogger could enter the contest by writing post about the raffle. As long as the post met some minimal criteria, like including a link to the contest page and another to my donation page, the blogger would be entered into the contest. I would supply some boilerplate text to make this easy to do.
3. Spread the word by email – Non-bloggers could spread the word and enter the contest by forwarding an email about the contest to at least X others and copying me on it. I’m thinking 5 might be a good number for X. I’m feeling a little hesitant about this part of the contest because it kinda feels like spam, but I want to give people who don’t have websites a chance to enter. What do you think?

One of my biggest fears is that I’d have plenty of people the word (since it’s essentially free) and nobody making donations. To make the donation option more attractive, I’m thinking I’d have donations count for two ballots in the raffle and word-spreading entries only count for one. I recognize that there is a built-in disincentive to spreading the word, since it opens the possibility to more ballots entering the contest and reduces the likelihood that the spreader will win, but I’m not sure that it will be enough.

Another problem that I worry about is that email word-spreaders will try to beat the system by forwarding email to garbage addresses. I thought I might reduce this problem by warning people up front that I intend to check any potential winner by writing to the email addresses to which the message was forwarded and confirming that there is a human (or something that sounds human) on the other end. Of course, this doesn’t stop scammers from forwarding all the copies of the email to themselves, using a different alias for each copy.

One of my other concerns is that by turning my fund-raising into a contest for personal gain, I might be robbing potential donors of feeling they are good people. It seems to be setting up a perfect situation for an internal moral conflict: am I good person for giving to a worthy cause or a bad one because I want to win an iPod? I’m afraid it could backfire and paralyze people from doing anything.

What are your impressions? Would you participate? How?

Any suggestions for how to set up the numbers for the contest? How many ballots would you enter for donations versus word-spreading? How big of a donation would require? How many emails would you require to forward?

Finally, are you interested in donating an iPod for the raffle? I’d make sure to have your name (or the name of your company) gratuitously plastered on all the related material. It could make for a good promotional tool you or your company. Email me if you’re interested: kd@kendyck.com.

Bird Lives!

charlieparker

Originally uploaded by hablando del asunto.

I recently finished reading Ross Russell’s Bird Lives!, a biography of Charlie Parker, the legendary jazz saxophonist who revolutionized the world of jazz in the early 1940s.

One of the things that surprised me on reading the book is just how unremarkable Parker was as a young musician.

We all hear stories of young Mozart; how audiences were astounded by his musical talents as a child. Mozart seemed to have some inexplicable innate musical from the moment of his birth.

Not Parker.

He was relatively late coming to music. He didn’t pick up an instrument until he was in high school. When he did, all accounts indicate that he was awful. For years he was considered a joke amongst his local Kansas City musicians, if they noticed him at all. His tone was terrible. He didn’t have any real understanding of music theory or harmony. He just plain sucked.

But what he might have lacked in raw talent, he more than made up in dedication. He spent every spare minute practicing. Despite several demoralizing incidents at local jam sessions — all of his early attempts to solo in public ended badly; one with the drummer throwing a cymbal to the floor to get him off the stage — he continued practicing. He was determined to master the alto sax.

He did eventually, of course. He spent a summer learning to play the solos off some Lester Young records and learning music theory from other trained musicians. Slowly he became competent. Then he became good. He kept working at it until he became the great player that history remembers him for.

While reading the biography, I was reminded of an article Kathy Sierra wrote about becoming an expert:

The only thing standing between you-as-amateur and you-as-expert is dedication. All that talk about prodigies? We could all be prodigies (or nearly so) if we just put in the time and focused. At least that’s what the brain guys are saying. Best of all–it’s almost never too late.

I’m not suggesting you can consider Charlie Parker a typical example of anything, but his experience does seem to support what Kathy is saying.

Dedication makes a difference.

I find that encouraging.

5 Things

The Mighty Sally tagged me, so here are five things you probably don’t know about me.

1. I was shot in the head with a BB gun when I was four years old by an older kid next door. I don’t remember much about the event itself but I remember the doctor yanking the shot out with a pair of pliers afterwards and showing it to me. I thought it was neat-o.
2. I wore a mullet in a pony tail in high school. I attribute this lapse in judgment to my childhood head wound.
3. I’ve never had a cavity. I’d thank my dentist father for training me in proper dental hygiene but The Mighty Sally had the same training when she was young and ended up with a mouthful. I’m just lucky, I guess.
4. I can recite the Pythagorean theorem from memory on cue. Don’t think that I’m bragging. I’m aware this is nothing to be proud of.
5. I’m a video game addict. If you are wondering why I’ve made so few posts lately, blame Final Fantasy XII.

Now to tag some more victims. Let’s see… how about Mandy, Larry, Kempton, and Michael?

New Year’s at Disney

Mandy and I rang in the New Year at Disney World in Florida. If you’re interested, check out the photo set.

One bit of advice if you are planning a trip to Disney World over the Christmas/New Year’s holidays: expect a crowd. The week between Chrismas and New Year’s is their busiest of the year. On New Year’s Eve, the Magic Kingdom was filled to capacity — over 70,000 people — and spent much of the day closed to visitors who weren’t staying on the resort.

The crowds practically disappear after New Year’s Day, though. The contrast was remarkable — especially with the Extra Magic Hours that we were able to take advantage of, being resort guests and all. In the days following New Year’s, we were able to made it on all the rides we wanted, usually with less than a 15 minute wait. That includes rides like Expedition Everest (highly recommended) and the Rock ‘n Rollercoaster (oh yeah!).